js判断是微信、QQ内置浏览器打开页面

需求

微信扫码下载,倘若是微信或qq内置浏览器打开,提示用本机内置浏览器打开

解决方法

 // 是微信内部webView
        if (is_weixn()) {
            alert("请点击右上角按钮, 点击使用浏览器打开");
        }

        if(is_qq()){
          alert("请点击右上角按钮, 点击使用浏览器打开");
        }
        // 是微信浏览器
        function is_weixn() {
            var ua = navigator.userAgent.toLowerCase();
            if (ua.match(/MicroMessenger/i) == "micromessenger") {
                return true;
            } else {
                return false;
            }
        }
        function is_qq(){
          var sUserAgent =navigator.userAgent.toLowerCase();
          if( sUserAgent.match(/QQ/i) == 'qq'){
            return true
          }else{
            return false
          }
        }
posted @ 2018-10-19 10:02  raindi  阅读(3066)  评论(0编辑  收藏  举报