Skip to content

Instantly share code, notes, and snippets.

@fwon
Forked from anhulife/WeixinDetection.js
Created May 18, 2016 09:49
Show Gist options
  • Save fwon/6adc90396d3f6aa68eae7a265c14e6f8 to your computer and use it in GitHub Desktop.
Save fwon/6adc90396d3f6aa68eae7a265c14e6f8 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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment