内核终端判断,微信?QQ?ipad?IE?移动?Google?opera……

 1  $(document).ready(function(){
 2         //判断访问终端
 3         var browser={
 4             versions:function(){
 5                 var u = navigator.userAgent, app = navigator.appVersion;
 6                 return {
 7                     trident: u.indexOf('Trident') > -1, //IE内核
 8                     presto: u.indexOf('Presto') > -1, //opera内核
 9                     webKit: u.indexOf('AppleWebKit') > -1, //苹果、谷歌内核
10                     gecko: u.indexOf('Gecko') > -1 && u.indexOf('KHTML') == -1,//火狐内核
11                     mobile: !!u.match(/AppleWebKit.*Mobile.*/), //是否为移动终端
12                     ios: !!u.match(/(i[^;]+;( U;)? CPU.+Mac OS X/), //ios终端
13                     android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1, //android终端
14                     iPhone: u.indexOf('iPhone') > -1 , //是否为iPhone或者QQHD浏览器
15                     iPad: u.indexOf('iPad') > -1, //是否iPad
16                     webApp: u.indexOf('Safari') == -1, //是否web应该程序,没有头部与底部
17                     weixin: u.indexOf('MicroMessenger') > -1, //是否微信 (2015-01-22新增)
18                     qq: u.match(/QQ//i) == "QQ/"  //是否QQ
19                 };
20             }(),
21             language:(navigator.browserLanguage || navigator.language).toLowerCase()
22         }
23 
24             if (browser.versions.weixin) {
25                 $(".mask").show();
26                 $("#tip").show();
27 
28             }else{
29                 window.location.href = 'http://uustar.pynoo.cn/download/uustar-admin-v2.0.2.apk';
30             }
31         $("#tip").on("click",function(){
32             $(".mask").hide(); $("#tip").hide();
33 
34         });
35 
36     })
原文地址:https://www.cnblogs.com/zhanghuiyun/p/5707636.html