JavaScript 判断手机端操作系统(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;
            } 
原文地址:https://www.cnblogs.com/xcxcxcxc/p/5541161.html