Home > Article > Web Front-end > How to use JavaScript to determine whether it is a WeChat scan code
This article introduces you to the JS method of judging whether it is a WeChat scan code through code. It is very good. Friends who need it can refer to it.
1. In the userAgent attribute of navagitor, judge whether Contains micromessenger
2. Code
/** * 判断微信扫码 */ function isWechat() { var ua = navigator.userAgent.toLowerCase(),flag = false; // if(ua.match(/MicroMessenger/i) === "micromessenger"){ if(ua.indexOf("micromessenger") > -1){ flag = true; }else { flag = false; } return flag; }
The above is the detailed content of How to use JavaScript to determine whether it is a WeChat scan code. For more information, please follow other related articles on the PHP Chinese website!