Js identifies Android, ios, and pc terminals, as well as shielding
This function is mainly used for download,
Android is definitely different from ios,
How to jump to a device based on the user's device during access from different devices.
In addition, if the accessed address is yes, the redirection will be blocked.
You need to identify and prompt to use another browser to open this URL.
The code is simple. The complete code is as follows:
1 2
3 4 5 6 11 <script> 12 function detectOS () {13 var osUserAgent = navigator. userAgent. toLowerCase (); 14 if (osUserAgent. indexOf ("iphone")>-1 | osUserAgent. indexOf ("ipad")>-1 | osUserAgent. indexOf ("ipod")>-1) {15 if (osUserAgent. indexOf ("micromessenger")>-1) {16 return "wechat"; 17} 18 // alert ("Note: Only jailbreak users can install"); 19 top. location. href = 'HTTP: // www.apple.com/'000020 return "iphone"; 21} 22 if (osUserAgent. indexOf ("android")>-1 | osUserAgent. indexOf ("adr")>-1) {23 if (osUserAgent. indexOf ("micromessenger")>-1) {24 return "wechat"; 25} 26 top. location. href = 'HTTP: // www.baidu.com '; 27 return "android"; 28} 29 if (osUserAgent. indexOf ("win")>-1) {30 top. location. href = 'HTTP: // www.baidu.com '; 31 return "windows"; 32} 33 return osUserAgent; 34} 35 detectOS (); 36 </script> 383940
4142
Three if statements are used for query: ios, Android, or win (pc ),
Added
If (osUserAgent. indexOf ("micromessenger")>-1) {return "wechat";} verify whether it is enabled in. if you do not need this function, delete it.
Top. location. href = 'HTTP: // www.apple.com/'specifies the address of the corresponding device. Finally, there is an image in the body. When it is accessed, the image is displayed, and the image content is prompted to be opened in another browser.