-
-
Save wonglok/00a13f31eedfc2f601b3 to your computer and use it in GitHub Desktop.
JavaScript 判断是否微信内置浏览器
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 使用 userAgent 判断是否微信内置浏览器 | |
// 不推荐使用 用户可能会自行修改浏览器的 userAgent | |
if( navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 || typeof navgator.wxuserAgent !== "undefined" ) { | |
return true; | |
} | |
// 使用微信 JS 对象判断是否微信内置浏览器 | |
// 建议使用此方法进行判断 | |
if( typeof WeixinJSBridge !== "undefined" ) { | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment