1. 非常实用的js判断手机端操作系统(Andorid/IOS),并自动跳转相应下载界面
  2. androidURL = "http://xxx/xxx.apk";
  3.  
  4. var browser = {
  5. versions: function() {
  6. var u = navigator.userAgent,
  7. app = navigator.appVersion;
  8. return {
  9.  
  10. android: u.indexOf('Android') > -1 || u.indexOf('Linux') > -1,
  11.  
  12. iPhone: u.indexOf('iPhone') > -1 ,
  13.  
  14. iPad: u.indexOf('iPad') > -1,
  15. iPod: u.indexOf('iPod') > -1,
  16.  
  17. };
  18. } (),
  19. language: (navigator.browserLanguage || navigator.language).toLowerCase()
  20. }
  21. if (browser.versions.iPhone||browser.versions.iPad||browser.versions.iPod)
  22. {
  23. //如果是ios系統,直接跳轉至appstore該應用首頁,傳遞参數为該應用在appstroe的id號
  24. window.location.href="itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=123456";
  25. }
  26. else if(browser.versions.android)
  27. {
  28. window.location.href = androidURL;
  29. }

第二种方案:

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

返回
顶部