JS判断用户是否使用微信客户端打开网页

来源:互联网 发布:黄金指赚钱软件 编辑:程序博客网 时间:2024/04/28 05:18
<script>  /**  * 判读是否是微信客户端  * @return true - 微信客户端打开; false - 其他浏览器打开页面  */  function is_wechat_client(){      var ua = navigator.userAgent.toLowerCase();      if(ua.match(/MicroMessenger/i)=="micromessenger"){          return true;      }else{          return false;      }  }</script>


加在页面头部即可判断,直接调用is_wechat_client(); 使用微信客户端打开链接的时候会返回true

0 0