Created
January 17, 2014 09:22
-
-
Save anhulife/8470534 to your computer and use it in GitHub Desktop.
判断网页是否是在微信内嵌浏览器中打开
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
document.addEventListener('WeixinJSBridgeReady', function(){ | |
//如果执行到这块的代码,就说明是在微信内部浏览器内打开的. | |
alert('当前页面在微信内嵌浏览器中打开!'); | |
}); |
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
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
两个方法 都是可以的是吧?