With the popularization of mobile devices, the network publicity of enterprises can no longer be limited to the PC side, but needs to build on the mobile side at the same time. For the company website, it used to be on the PC side. Of course, mobile terminals such as mobile phones can also access it, but the user experience is certainly not as convenient as the completely suitable mobile terminal. After we have built a WAP mobile website for our website, if a user visits our corporate TLD website through mobile phone, then we will judge to jump to the dedicated WAP website.
Here, Lao Zuo has sorted out the two JS scripts he is currently using. I have been asked by friends before, so I share them here.
The first type: direct JS script
<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=" https://www.laozuo.org (Change to your own WAP website) ";
}
}
}
catch(err)
{
}</script>
The second one is slightly longer
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){}
}
Keep the above script to 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(" https://www.laozuo.org (Change to your own WAP website) ");</script>
Both methods can be used. I can test them on Android and IPHONE.