JavaScript 判断手机端操作系统(Andorid/IOS)

来源:互联网 发布:网络视频用户规模 编辑:程序博客网 时间:2024/05/20 16:34
            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;            } 

 

0 0