First, embed this code in your head.
<script src= "Http://siteapp.baidu.com/static/webappservice/uaredirect.js" type= "Text/javascript" ></ Script>
<script type= "Text/javascript" >uaredirect ("http://m.caijiayou.com", "http://www.caijiayou.com"); </ Script>
The second line of the style reference this is OK. Change the domain name inside to your own.
Here we can see, this is quoted Baidu Siteapp Uaredirect.js
So you can also download the JS file to your website locally.
: Http://siteapp.baidu.com/static/webappservice/uaredirect.js
We'll format the uaredirect.js.
uaredirect.js after formatting
Function Uaredirect (f) {
try{
if (document.getElementById ("Bdmark")!=null) {
return
}
Var b=false ;
if (arguments[1]) {
var e=window.location.host;
var a=window.location.href;
if (Issubdomain (arguments[1],e) ==1) {
f=f+ "/#m/" +a;b=true
}else{
if (Issubdomain (arguments[1],e) ==2) {
f=f+ "/#m/" +a;b=true
}else{
F=a;b=false
}
}
}else{
B=true
}if (b) {
var c= Window.location.hash;
if (!c.match ("Fromapp")) {
if (Navigator.userAgent.match (/(iphone|ipod| Android|ios)) {
Location.replace (f)}
}
}
}catch (d) {
}
}
function Issubdomain (c,d) {
This.getdomain=function (f) {
var e=f.indexof ("://");
if (e>0) {
var h=f.substr (e+3)
}else{
var h=f
}
var g=/^www\./;
if (G.test (h)) {
H=H.SUBSTR (4)
}
Return h
};
if (C==d) {
Return 1
}else{
var c=this.getdomain (c);
var b=this.getdomain (d);
if (c==b) {
Return 1
}else{
C=c.replace (".", "\ \.");
var a=new RegExp ("\ \.") +c+ "$");
if (B.match (a)) {
Return 2
}else{
return 0
}
}
}
};
From the above JS can be seen in the different access to the judgment.
Using Baidu Siteapp uaredirect.js to judge the user access to the domain name of the auto-jump