First of all, I want to tell you my project requirements: Users sweep a two-dimensional code will produce a link, the link will send a request back to a apk download address, users click the download button can download this apk. Then there is a problem, after testing, found with a micro-letter sweep open Page Click download button can not download apk, after Baidu, the original is a micro-letter built-in browser shielding the download link, the back and demand side communication, the need to change if the user is using a micro-letter built-in browser open, prompts the user to change a browser to open the page, Otherwise download is not apk. So how can you tell if the user is using a micro-mail browser?
We know that JS can use window.navigator.userAgent to get information about the browser, such as: mozilla/5.0 (Windows NT 5.1) applewebkit/537.36 (khtml, like Gecko chrome/33.0.1750.154 safari/537.36, then we can also use this method to obtain information about the micro-letter built-in browser: mozilla/5.0 (iPhone; CPU iPhone os 7_1_1 like Mac os X applewebkit/537.51.2 (khtml, like Gecko) mobile/11d201 micromessenger/5.3. Based on the keyword micromessenger to determine whether the micro-mail built-in browser. The judgment function is as follows:
function Isweixin () {
var ua = Window.navigator.userAgent.toLowerCase ();
if (Ua.match (/micromessenger/i) = = ' Micromessenger ') {return
true;
} else{return
false;
}
Demo
Description: You can put the above demo on the server, and then generate a two-dimensional code sweep.
The above is a small set to introduce JavaScript to judge the micro-letter browser Instance code knowledge, hope to help everyone, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!