• js网页判断移动终端浏览器版本信息是安卓还是苹果ios,判断在微信浏览器跳转不同页面,生成二维码


    一个二维码,扫描进入网页,自动识别下载苹果和安卓客户端,判断网页如下,(只有苹果的微信不能自动跳转)所以加个微信判断.

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>移动终端浏览器版本信息</title>
        </head>
        <body>
    <script type="text/javascript">
    var browser = {
      versions: function () {
      var u = navigator.userAgent, app = navigator.appVersion;
      return {//移动终端浏览器版本信息
       trident: u.indexOf('Trident') > -1, //IE内核
       presto: u.indexOf('Presto') > -1, //opera内核
       webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
       gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1, //火狐内核
       mobile: !!u.match(/AppleWebKit.*Mobile/i) || !!u.match(/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/), //是否为移动终端
       ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
       android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, //android终端或者uc浏览器
       iPhone: u.indexOf('iPhone') > -1 || u.indexOf('Mac') > -1, //是否为iPhone或者QQHD浏览器
       iPad: u.indexOf('iPad') > -1, //是否iPad
       webApp: u.indexOf('Safari') == -1 //是否web应该程序,没有头部与底部
      };
      } (),
      language: (navigator.browserLanguage || navigator.language).toLowerCase()
    }
    if (browser.versions.iPhone || browser.versions.iPad || browser.versions.ios) {//苹果版
         
    window.location.href = "https://itunes.apple.com/us/app/bei-jing-xin-xi-wang-huo-dong/id1097486612?mt=8";
    is_weixn();//苹果微信不自动跳转浏览器
    }
    if (browser.versions.android) {//安卓
    window.location.href = "http://active.bjxxw.com/Appdown/active.apk";
    }
    // 是否为微信
    function is_weixn(){  
        var ua = navigator.userAgent.toLowerCase();  
        if(ua.match(/MicroMessenger/i)=="micromessenger") {  
            alert('微信请在右上角浏览器中打开');
        } else {  
            return false;  
        }  
    }  
    </script>
        </body>
    </html>
     
  • 相关阅读:
    QtQt Creator 操作快捷键大全
    go编译报错https://proxy.golang.org/github.com/ i/o timeout
    常用坐标系
    10 种CORS跨域解决方案
    centos问题解决方案汇总
    org.apache.axis.AxisFault: 服务器无法处理请求。 > 值不能为空。
    PHP 开启 curl_init
    帝国CMS 标签 showclasstemp
    帝国CMS 标签 listsonclass
    PHP 获取服务器 MAC 物理网卡地址
  • 原文地址:https://www.cnblogs.com/hiit/p/5627201.html
Copyright © 2020-2023  润新知