-
-
Save xiaoshude/6330da83146614cb9fd2cc1ef2270281 to your computer and use it in GitHub Desktop.
JavaScript 判断是否微信内置浏览器
This file contains hidden or 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
var isWeixin = false; | |
if (typeof WeixinJSBridge == "object" && typeof WeixinJSBridge.invoke == "function") { | |
isWeixin = true; | |
} else { | |
if (document.addEventListener) { | |
document.addEventListener("WeixinJSBridgeReady", function() { isWeixin = true; }, false); | |
} else if (document.attachEvent) { | |
document.attachEvent("WeixinJSBridgeReady", function() { isWeixin = true; }); | |
document.attachEvent("onWeixinJSBridgeReady", function() { isWeixin = true; }); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment