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
          }
        }
相關文章
相關標籤/搜索