zoukankan      html  css  js  c++  java
  • js判断手机端操作系统(Andorid/IOS)

    非常实用的js判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面
     androidURL = "http://xxx/xxx.apk";
     
     
                var browser = {
                    versions: function() {
                        var u = navigator.userAgent,
                        app = navigator.appVersion;
                        return {
          
                            android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
    
                            iPhone: u.indexOf('iPhone') > -1 ,                      
    
                            iPad: u.indexOf('iPad') > -1,
                            iPod: u.indexOf('iPod') > -1,
       
                        };
                    } (),
                    language: (navigator.browserLanguage || navigator.language).toLowerCase()
                }
                if (browser.versions.iPhone||browser.versions.iPad||browser.versions.iPod)
                {
                     //如果是ios系統,直接跳轉至appstore該應用首頁,傳遞参數为該應用在appstroe的id號
                     window.location.href="itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=123456";
                }
                else if(browser.versions.android)
                {
                    window.location.href = androidURL;
                } 

    转载请注明(B5教程网)原文链接:http://www.bcty365.com/content-69-1807-1.html

    第二种方案:

    <script language="javascript">
    window.onload = function () {
    alert("1");
    var u = navigator.userAgent;
      document.write(typeof(navigator.platform)=="undefined"?"":navigator.platform)//输出对应的手机系统
    if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机
    alert("安卓手机");
    // window.location.href = "mobile/index.html";
    } else if (u.indexOf('iPhone') > -1) {//苹果手机
    // window.location.href = "mobile/index.html";
    alert("苹果手机");
    } else if (u.indexOf('Windows Phone') > -1) {//winphone手机
    alert("winphone手机");
    // window.location.href = "mobile/index.html";
    }
    }
    </script>

    原文地址:http://www.cnblogs.com/lyl6796910/p/3700151.html

  • 相关阅读:
    C# 日期帮助类【原创】
    C# 发送邮件
    每日一题力扣453
    每日力扣628
    每日一题力扣41巨坑
    每日一题力扣274
    每日一题力扣442有坑
    每日一题力扣495
    每日一题力扣645
    每日一题力扣697
  • 原文地址:https://www.cnblogs.com/zxyun/p/4784515.html
Copyright © 2011-2022 走看看