Skip to content

Instantly share code, notes, and snippets.

@anhulife
Created January 17, 2014 09:22
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save anhulife/8470534 to your computer and use it in GitHub Desktop.
Save anhulife/8470534 to your computer and use it in GitHub Desktop.
判断网页是否是在微信内嵌浏览器中打开
document.addEventListener('WeixinJSBridgeReady', function(){
//如果执行到这块的代码,就说明是在微信内部浏览器内打开的.
alert('当前页面在微信内嵌浏览器中打开!');
});
isWeixinBrowser(){
//截至2014年2月12日,这个方法不能测试windows phone中的微信浏览器
return (/MicroMessenger/i).test(window.navigator.userAgent);
}
@Liqiankun
Copy link

两个方法 都是可以的是吧?

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