标签:根据 roi user logs play lower ipa mic isp
根据userAgent判断浏览器类型,移动端,PC端,微信,QQ和微博
var os = function () {
var ua = navigator.userAgent.toLowerCase(),
isAndroid = /(?:android)/.test(ua),
isWeChat = /(?:micromessenger)/.test(ua),
isQQ = /(?:qq)/.test(ua),
isWeiBo = /(?:weibo)/.test(ua),
isTablet = /(?:ipad|playbook)/.test(ua) || (isAndroid && !/(?:mobile)/.test(ua)),
isPhone = /(?:iphone)/.test(ua) && !isTablet,
isPc = !isPhone && !isAndroid && !isTablet;
return {
isTablet: isTablet,// 平板
isPhone: isPhone, // 苹果
isAndroid: isAndroid, //安卓
isWeChat: isWeChat, //微信
isQQ: isQQ, // QQ
isWeiBo: isWeiBo, // 微博
isPc: isPc // PC端
};
}();
//使用
if (os.isPc) {
console.log(‘isPc :‘);
} else if (os.isAndroid) {
console.log(‘isAndroid‘);
}
else if (os.isPhone) {
console.log(‘isPhone‘);
}
end !
标签:根据 roi user logs play lower ipa mic isp
原文地址:http://www.cnblogs.com/web-wangmeng/p/7447580.html