温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

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

发布时间:2020-07-19 16:22:45 来源:网络 阅读:1335 作者:gutaotao1989 栏目:开发技术

网上搜集的 不知道实用不 先收藏了

<script type="text/javascript">

 var commonURL = 'http://www.jsdaima.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("跳转地址");/*指定跳转地址*/

 </script>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI