javascript 的一些小知识应用点

一、判断是否是微信浏览器

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>



 

猜你喜欢

转载自blog.csdn.net/u011146423/article/details/85257156