获取浏览器类型通用JS 方法 通常用来判断 是 PC端还是移动端 getBrower.js
获取浏览器类型通用JS 方法
//获取浏览器-pc/wap
window.getBrower = function () {
var u = navigator.userAgent.toLowerCase(),
isPad = false, isAndroidPad = false, isIpad = false, isMobile = false, isPc = false;
if (u.indexOf(''))
if (u.indexOf('android') > -1) {
if (u.indexOf('mobile') == -1) {
isAndroidPad = true;
}
}
if (u.indexOf('ipad') > -1) {
isIpad = true;
}
if (isAndroidPad || isIpad) {
isPad = true;
} else if ((u.indexOf('mobile') > -1 && !isPad) || (u.indexOf('android') > -1 && !isAndroidPad) || (u.indexOf('phone') > -1)) {
isMobile = true;
} else {
isPc = true;
}
return {
android: u.indexOf('android') > -1 || u.indexOf('Linux') > -1,
iPhone: u.indexOf('iphone') > -1,
isPad: isPad,
isMobile: isMobile,
isPc: isPc,
wx: u.toLowerCase().indexOf('micromessenger') > -1,
};
};