Home >Web Front-end >JS Tutorial >Implement WeChat scan to download APP based on JavaScript code_JavaScript
There are many people doing WeChat scan and download. However, after the WeChat update, WeChat banned this function. It cannot be said to be a complete ban, because Tencent and WeChat are the same company. It seems that applications that have passed the App Bao review can still be downloaded directly by scanning the QR code. But it will still take time to pass the review, so use the following paragraph (top of dry information) to solve the problem. By making a guide page, generate the URL of the page into a QR code (I use CaoMao QR code) code generator). Determine whether it is the core of WeChat for boot download. If it is opened directly using a browser (such as: uc), then download the app directly. If it is the WeChat kernel, it means that it is opened in WeChat's built-in browser, then a guide icon will appear to guide the user to open it with the browser, and then download it directly after opening it with the browser.
Scan with WeChat to download the app code snippet as shown below:
<script type="text/javascript"> var weixin=document.getElementById("weixinStyle"); window.onload=function(){ /* * 判断是否为微信内核 是 则显示引导图标 否则 不显示直接下载 * */ if(isWeixin()){ weixin.className = "show"; }else{ location.replace("写入你的apk网络下载地址"); } } function isWeixin(){ var WxObj=window.navigator.userAgent.toLowerCase(); if(WxObj.match(/microMessenger/i)=='micromessenger'){ return true; }else{ return false; } } </script>
Okay, I will write this much code for you first. You can expand your knowledge based on the above content according to your own needs. I hope the above can help you.