var u = navigator.userAgent; //Android终端 var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //iOS终端 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
1.、 isAndroid和isiOS是两个布尔值 //判断设备是安卓或者是ios
var ua = navigator.userAgent; var isWeixin = !!/MicroMessenger/i.test(ua);
2、isWeixin也是布尔值 //判断是否是微信