一、判断是否是微信浏览器
var wx= (function(){
return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
}
)();
if(wx){
alert("是微信");
}else {
alert("不是微信");
}
二、手机浏览器打开微信app
// 安卓:
var state = null;
try {
if (scheme != '') {
openIframe.src = '【scheme】://【host】/【openwith】';
}
} catch (e) { }
if (state) {
window.close();
} else {
location.href='下载地址';
}
// 苹果:
if (scheme != '') {
window.location.href = '【scheme】://';
}
// a标签:
<a href="weixin://" class="gowx" id="gowxtext">复制好了 添加好友 </a>