How to judge whether the page is opened by QQ browser or WeChat browser


// Judging whether it is the js code of QQ browser or WeChat browser
isWx = function() {
var ua = navigator.userAgent.toLowerCase();
return ua.match(/MicroMessenger/i) == 'micromessenger';
},
/ / whether QQ
isQQ = function() {
var ua = navigator.userAgent.toLowerCase();
return !!ua.match(/mqqbrowser|qzone|qqbrowser/i);
}

//Judgment, if-elseif order cannot be reversed
if (isWx()) {
alert('WeChat sharing')
//It is WeChat
} else if (isQQ()) {
alert('It is QQ')
//It is QQ
}

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325085103&siteId=291194637