Skip to content

Instantly share code, notes, and snippets.

@luokailuo
Last active April 11, 2016 02:23
Show Gist options
  • Save luokailuo/7458e8dbfdde4074ef8d3a0b20d75011 to your computer and use it in GitHub Desktop.
Save luokailuo/7458e8dbfdde4074ef8d3a0b20d75011 to your computer and use it in GitHub Desktop.
Javascript 判断是否微信内置浏览器
/* 判断 window.navigator.userAgent 中是否含有关键字:micromessenger */
function isWeiXinBrowser() {
var ua = window.navigator.userAgent.toLowerCase();
console.log(ua);
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
if(isWeiXinBrowser()){
console.log("是微信内置浏览器")
}else{
console.log("不是微信内置浏览器")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment