Here we only need to use a simple JS judgment to achieve the jump. The following two methods have been used by Lao Jiang before. If you need them, you can refer to adding them to the website.
First:
The code is as follows: |
Copy code |
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 ){}
}
|
Save the above file to the shouji. js file and reference it in the website to be called.
The code is as follows: |
Copy code |
<Script src = "shouji. js" type = "text/javascript"> </script>
<Script type = "text/javascript"> uaredirect ("http://www.itbulu.com/"); </script>
|
The red part is replaced with our WAP site.
Second:
The code is as follows: |
Copy code |
<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.itbulu.com /";
}
}
}
Catch (err)
{
} </Script>
|
Directly add a JS file to the required page, and replace the URL with ours. This type can also be encapsulated in the JS file and called. It can be used to re-adjust some published site information. The first type is directly added to the site.
To sum up, the above two mobile browsers have been able to determine that the method for redirecting to the WAP website JS file has been tested. Generally, there is no problem.