Automatically determine the mobile phone version and pc version, and determine the mobile phone pc
<Html>
<Head>
<Title> welcome to mobile edition </title>
<Script>
Var ua = navigator. userAgent;
Var US = {
Android: function () {// Android
Return ua. match (/Android/I )? True: false;
},
BlackBerry: function () {// BlackBerry
Return ua. match (/BlackBerry/I )? True: false;
},
IOS: function () {// IOS
Return ua. match (/iPhone | iPad | iPod/I )? True: false;
},
// This is actually unnecessary. You don't have to judge this. After all, IE is an old thing.
Windows: function (){
Return ua. match (/IEMobile/I )? True: false;
},
IsMobile: function () {// mobile device
Return US. Android () | US. BlackBerry () | US. IOS () | US. Windows ();
}
}
If (US. isMobile () = false ){
Window. location = "http://www.baidu.com"; // if it is a computer access, jump into the specified URL. Take Baidu as an Example
}
</Script>
</Head>
<Body> </Html>