js判断手机端操作系统(Andorid/IOS)
非常实用的js判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面<br/> androidURL = "http://xxx/xxx.apk"; var browser = {<br/> versions: function() {<br/> var u = navigator.userAgent,<br/> app = navigator.appVersion;<br/> return { android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1, iPhone: u.indexOf('iPhone') > -1 , iPad: u.indexOf('iPad') > -1,<br/> iPod: u.indexOf('iPod') > -1, };<br/> } (),<br/> language: (navigator.browserLanguage || navigator.language).toLowerCase()<br/> }<br/> if (browser.versions.iPhone||browser.versions.iPad||browser.versions.iPod)<br/> {<br/> //如果是ios系統,直接跳轉至appstore該應用首頁,傳遞参數为該應用在appstroe的id號<br/> window.location.href="itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=123456";<br/> }<br/> else if(browser.versions.android)<br/> {<br/> window.location.href = androidURL;<br/> }
转载请注明(B5教程网)原文链接:http://www.bcty365.com/content-69-1807-1.html
第二种方案:
<script language="javascript"><br/> window.onload = function () {<br/> alert("1");<br/> var u = navigator.userAgent;
document.write(typeof(navigator.platform)==”undefined”?””:navigator.platform)//输出对应的手机系统
if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) {//安卓手机<br/> alert("安卓手机");<br/> // window.location.href = "mobile/index.html";<br/> } else if (u.indexOf('iPhone') > -1) {//苹果手机<br/> // window.location.href = "mobile/index.html";<br/> alert("苹果手机");<br/> } else if (u.indexOf('Windows Phone') > -1) {//winphone手机<br/> alert("winphone手机");<br/> // window.location.href = "mobile/index.html";<br/> }<br/> }<br/> </script>