js 判断手机浏览器类型。亲测有效 | 前端大队长

js 判断手机浏览器类型。亲测有效

var UA = navigator.appVersion;
var u = navigator.userAgent;
var ios = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) ? 1 :0;
var brower = 'other-0'
var isqqBrowser = (u.toLowerCase().match(/mqqbrowser/)) ? '1' : '0';
var isucBrowser = (UA.split("UCBrowser/").length > 1) ? '1' : '0';
var issafBrowser = (u.toLowerCase().match(/version\/([\d.]+).*safari/) && ios && !u.toLowerCase().match(/mqqbrowser/)) ? '1' : '0';
if(isqqBrowser==='1'){brower = 'qqmobile'}else if(isucBrowser==='1'){brower = 'ucmobile'}else if(issafBrowser==='1'){brower = 'safarimobile'};
brower = brower + '-'+ ios;
console.log(brower)

 

 

 

 

哈哈

Latest posts by admin (see all)