<script type= "Text/javascript" >
try {
var urlhash = Window.location.hash;
if (!urlhash.match ("Fromapp"))
{
if (Navigator.userAgent.match (/(iphone|ipod| Android|ios|ipad)))
{
Window.location= "http://www.laozuo.org (change to own WAP website)";
}
}
}
catch (Err)
{
}</script>
The second kind, a little longer, references
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))) {
Location.replace (Murl);
}
}
} catch (Err) {}
}
The above script is persisted to the Mobile.js file, and then the following 2 JS call files are referenced in the page that needs to be called.
<script src= "Mobile.js" type= "Text/javascript" ></script>
<script type= "Text/javascript" >uaredirect ("http://www.laozuo.org (change to own WAP website)");</script>
Both methods can be used, and my test on Android and iphone is feasible.
2 JS script to determine mobile browser jump WAP Mobile website