1 判断浏览器内核做页面跳转 2 3 4 5 var browser = { 6 7 versions: function() { 8 9 var u = navigator.userAgent, app = navigator.appVersion; 10 11 return {//移动终端浏览器版本信息 12 13 trident: u.indexOf(‘Trident‘) > -1, //IE内核 14 15 presto: u.indexOf(‘Presto‘) > -1, //opera内核 16 17 webKit: u.indexOf(‘AppleWebKit‘) > -1, //苹果、谷歌内核 18 19 gecko: u.indexOf(‘Gecko‘) > -1 && u.indexOf(‘KHTML‘) == -1, //火狐内核 20 21 mobile: !!u.match(/AppleWebKit.*Mobile.*/) || !!u.match(/AppleWebKit/), //是否为移动终端 22 23 ios: !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端 24 25 android: u.indexOf(‘Android‘) > -1 || u.indexOf(‘Linux‘) > -1, //android终端或者uc浏览器 26 27 iPhone: u.indexOf(‘iPhone‘) > -1 || u.indexOf(‘Mac‘) > -1, //是否为iPhone或者QQHD浏览器 28 29 iPad: u.indexOf(‘iPad‘) > -1, //是否iPad 30 31 webApp: u.indexOf(‘Safari‘) == -1 //是否web应该程序,没有头部与底部 32 33 }; 34 35 }(), 36 37 language: (navigator.browserLanguage || navigator.language).toLowerCase() 38 39 } 40 41 var ua = window.navigator.userAgent.toLowerCase(); 42 43 44 45 if(ua.match(/MicroMessenger/i) == ‘micromessenger‘){ 46 47 $(‘.wholePage‘).show(); 48 49 }else if(browser.versions.ios || browser.versions.iPhone || browser.versions.iPad){ 50 51 //$(‘#downMsg‘).show(); 52 53 location.href = ‘https://itunes.apple.com/cn/app/id1149168395‘; 54 55 }else{ 56 57 //$(‘#downMsg‘).show(); 58 59 location.href = "http://www1.zhiya100.com:8000/subject/app/zhiya100.apk"; 60 61 } 62 63 64 65 66 67 判断是否为移动端运行环境 68 69 70 71 var module1=(function(mod,$){ 72 73 mod.isMob=function(){// 判断是否为移动端运行环境 74 75 var mob=‘‘,v=window.navigator.userAgent; 76 77 if(/AppleWebKit.*Mobile/i.test(v) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(v))){ 78 79 if(window.location.href.indexOf("?mobile")<0){ 80 81 try{ 82 83 mob=‘true‘; 84 85 }catch(e){ 86 87 88 89 } 90 91 } 92 93 }else{ 94 95 mob=‘false‘; 96 97 } 98 99 return mob; 100 101 }; 102 103 return mod; 104 105 })(window.module1 || {},jQuery); 106 107 var mob=module1.isMob(); 108 109 110 111 112 113 判断是什么浏览器 114 115 116 117 var inBrowser = typeof window !== ‘undefined‘, 118 119 ua = inBrowser && window.navigator.userAgent.toLowerCase(), 120 121 isIE = ua && /msie|trident/.test(ua), 122 123 isIE9 = ua && ua.indexOf(‘msie 9.0‘) > 0, 124 125 isEdge = ua && ua.indexOf(‘edge/‘) > 0, 126 127 isChrome = ua && /chrome\/\d+/.test(ua) && !isEdge, 128 129 isSafari = ua && /version\/\d+/.test(ua) && !isEdge, 130 131 isFirefox = ua && /firefox\/\d+/.test(ua), 132 133 isOpera = ua && /opera.\d+/.test(ua), 134 135 isAndroid = ua && ua.indexOf(‘android‘) > 0, 136 137 isIOS = ua && /iphone|ipad|ipod|ios/.test(ua);