您现在的位置是:网站首页 >> 常见问题
常见问题

联 系 人:李总
联系电话:13759574266
在线 QQ:89417157
邮箱:13759574266@qq.com
微信号:ynlongtou
地址:昆明市滇缅大道旁昆建路5号108智库空间A座4楼

常见问题

前端判断访问站点设备(手机还是PC)实现自动跳转手机端代码

  手机访问PC端实现自动跳转手机端代码的实现方法有很多,云南龙头科技有限公司小编列出如下几种供大家参考:

第一种:使用百度出品的uaredirect.js来判断客户端是否为手机

<script src="http://www.ynlongtou.com/js-bak/uaredirect-baidu.js" type="text/javascript"></script><script type="text/javascript">uaredirect("http://www.ynlongtou.com/m");</script>

第二种:进入网站自动跳转

<meta http-equiv="refresh" content="0;url= /m ">

第三种:

<script type="text/javascript">

var commonURL = 'http://www.ynlongtou.com/';

function mobile_device_detect(url){

  var thisOS=navigator.platform;

  var os=new Array("iPhone","iPod","iPad","android","Nokia","SymbianOS","Symbian","Windows Phone","Phone","Linux armv71","MAUI","UNTRUSTED/1.0","Windows CE","BlackBerry","IEMobile");

  for(var i=0;i<os.length;i++){

    if(thisOS.match(os[i])){   

         window.location=url;

         }

  }

  if(navigator.platform.indexOf('iPad') != -1){

      window.location=url;

  }

  var check = navigator.appVersion;

      if( check.match(/linux/i) ){

          if(check.match(/mobile/i) || check.match(/X11/i)) {

         window.location=url;

        }  

      }

  Array.prototype.in_array = function(e){

    for(i=0;i<this.length;i++){

      if(this[i] == e)

      return true;

      }

      return false;

    }

  } 

mobile_device_detect("http://www.ynlongtou.com/m");/*指定跳转地址*/

</script>

第四种:

<script type="text/javascript">

(function(Switch){var switch_pc = window.location.hash;if(switch_pc != "#pc"){if(/iphone|ipod|Android|nokia|blackberry|webos|webos|webmate|bada|lg|ucweb|

skyfire|sony|ericss