在移动端网页开发中,我们经常需要判断浏览器类型,是在微信内置浏览器,还是QQ内置浏览器,或者是其他浏览器打开。
function is_weixn_qq(){
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i)=="micromessenger") {
return "wx"; //是微信
} else if (ua.match(/QQ/i) == "qq") {
return "qq"; //是QQ
}
return false; //其他浏览器
}