判断浏览器环境(QQ,微信,安卓设备,IOS设备,PC微信环境,移动设备)

时间:2021-04-05 16:01:20

判断浏览器环境(QQ,微信,安卓设备,IOS设备,PC微信环境,移动设备)


// ===== 判断浏览器环境 ===== // // 判断是否是QQ环境
function isQQ() {
return(navigator.userAgent.toLowerCase().match(/\bqq\b/i) == "qq")
} // 判断是否是微信环境
function isWeixin() {
return(navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == "micromessenger")
} // 判断是否是安卓设备
function isAndroid() {
return navigator.userAgent.indexOf("Android") > -1 || navigator.userAgent.indexOf("Linux") > -1
} // 判断是否是IOS设备
function isiOS() {
return !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
} // 判断是否是PC微信环境
function isPCWeixin() {
return(navigator.userAgent.toLowerCase().match(/WindowsWechat/i) == "windowswechat")
} // 是否是移动设备
function isMobile() {
for(var c = navigator.userAgent.toLowerCase(), b = "android;iphone;symbianos;windows phone;ipad;ipod".split(";"), a = 0; a < b.length; a++)
if(0 < c.indexOf(b[a])) return !0;
return !1
}