Skip to content

Instantly share code, notes, and snippets.

@cary929
Forked from loo2k/wechat-browser-detect.js
Created May 25, 2016 16:28
Show Gist options
  • Save cary929/b2bc9bc8e45fe150658828e971a62a22 to your computer and use it in GitHub Desktop.
Save cary929/b2bc9bc8e45fe150658828e971a62a22 to your computer and use it in GitHub Desktop.
JavaScript 判断是否微信内置浏览器
// 使用 userAgent 判断是否微信内置浏览器
// 不推荐使用 用户可能会自行修改浏览器的 userAgent
if( navigator.userAgent.toLowerCase().indexOf('micromessenger') > -1 || typeof navgator.wxuserAgent !== "undefined" ) {
return true;
}
// 使用微信 JS 对象判断是否微信内置浏览器
// 建议使用此方法进行判断
if( typeof WeixinJSBridge !== "undefined" ) {
return true;
}
@jerry-he
Copy link

这个方法无效,即便我是在loaded之后都无效

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment