Two JS scripts determine the mobile browser type to jump to the WAP mobile website, jswap
With the popularization of mobile devices, the network promotion of enterprises cannot be confined to PCs, but must be achieved at the same time on mobile terminals. For the company's website, it used to be a PC-end. Of course, mobile phones and other mobile terminals can also be accessed. However, the user experience is certainly not as convenient as that of mobile phones. After we create a WAP mobile website for our website, if a user accesses our enterprise top-level domain name website through a mobile phone, the user will jump to the specially designed WAP website.
Here, I have sorted out the two types of JS scripts that I am currently using, because I have been asking for them, so I will share them here.
First: Direct JS scripts
<Script type = "text/javascript"> try {var urlhash = window. location. hash; if (! Urlhash. match ("fromapp") {if (navigator. userAgent. match (/(iPhone | iPod | Android | ios | iPad)/I) {window. location = "http://www.laozuo.org (change to your own WAP website)" ;}} catch (err) {}</script>
Second, a little longer, reference
function uaredirect(murl){try {if(document.getElementById("bdmark") != null){return;}var urlhash = window.location.hash;if (!urlhash.match("fromapp")){if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iPad)/i))) {location.replace(murl);}}} catch(err){}}
The above scripts are kept in the mobile. js file, and then reference the following two JS call files on the page to be called.
<Script src = "mobile. js "type =" text/javascript "> </script> <script type =" text/javascript "> uaredirect (" http://www.laozuo.org (change to your own WAP site )"); </script>
After testing two js scripts, you can determine the type of the mobile browser to jump to the WAP mobile website. If you need them, you can use them directly.