-
The first method:
<script>
if (navigator.platform.indexOf (' Win32 ')!=-1) {
Pc
window.location.href= "Computer website";
}else{
Shouji
window.location.href= "Mobile url";
}
</script>
-
The second method:
<script type= "Text/javascript" >
function Browserredirect () {
var suseragent= navigator.userAgent.toLowerCase ();
var bisipad= suseragent.match (/ipad/i) = = "ipad";
var bisiphoneos= suseragent.match (/iphone os/i) = = "iphone OS";
var bismidp= suseragent.match (/midp/i) = = "MIDP";
var bisuc7= suseragent.match (/rv:1.2.3.4/i) = = "rv:1.2.3.4";
var bisuc= suseragent.match (/ucweb/i) = = "UCWeb";
var bisandroid= suseragent.match (/android/i) = = "Android";
var bisce= suseragent.match (/windows ce/i) = = "Windows CE";
var biswm= suseragent.match (/windows mobile/i) = = "Windows Mobile";
if (Bisipad | | bisiphoneos | | bismidp | | bIsUc7 | | bisuc | | bisandroid | | bisce | | biswm) {
Window.location.href= ' mobile website address ';
} else {
Window.location= ' computer website address ';
}
}
Browserredirect ();
</script>
-
Method Three:
<script type= "Text/javascript"
Var mobileagent = new array ("iphone", "ipod", "ipad", "Android", "mobile", "BlackBerry", "webOS", "incognito", "Webmate", "Bada", "Nokia", "LG", "UCWeb", "Skyfire");
Var browser = navigator.useragent.tolowercase ();
Var ismobile = false;
for (var i=0; i<mobileagent.length; i++) { if (Browser.indexOf (mobileAgent[ I])!=-1) { ismobile = true;
//alert (Mobileagent[i]);
location.href = ' mobile URL ';
break; } }
</script>
-
Fourth method:
<?php
////This section of the mobile phone station
Header (" Cache-control: no-cache ");
Header (" Pragma: no-cache ");
$ua = strtolower ($_server[' http_user_agent ');
$uachar = /(symbianos|android| Mac os|ucweb|blackberry)/I ";
If ($ua != ' && !preg_match ($uachar, $ua) {
echo ' window.location.href= "Computer address"; ';
Exit ();
}
?
<?php
//This paragraph is placed on the website
Header ("Cache-control: no-cache");
Header ("Pragma: no-cache");
$ua = strtolower ($_server[' http_user_agent ');
$uachar = /(symbianos|android| Mac os|ucweb|blackberry)/I ";
If ($ua != ' && preg_match ($uachar, $ua) {
echo ' window.location.href= "mobile address"; ';
Exit ();
}
?
-
The Fifth method:
<?php
function useragent () {
$user _agent = (!isset ($_server[' http_user_agent '))? FALSE: $_server[' http_user_agent '];
return $user _agent;
}
Mobile
if ((Preg_match ("/(iphone|ipod|android)/I", Strtolower (UserAgent ()))) and Strstr (Strtolower (useragent ()), ' WebKit ') ){
Header (' Location: Mobile URL ');
Exit
}else if (Trim (useragent ()) = = "or Preg_match ("/(nokia|sony|ericsson|mot|htc|samsung|sgh|lg|philips|lenovo|ucweb| Opera mobi|windows Mobile|blackberry)/i ", Strtolower (UserAgent ()))) {
Header (' Location: Mobile URL ');
Exit
}else{//pc
Header ("Location: Computer url");
}
?>
-
The sixth method, can also be named Uaredirect file download to their own website to introduce;
(Note: Put Uaredirect in Baidu Search will appear file specific address)
functionUaredirect (f) {Try{if(document.getElementById ("Bdmark")! =NULL){return}varb=false;if(Arguments[1]) {varE=window.location.host;varA=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) {varC=window.location.hash;if(!c.match ("Fromapp")) {if((Navigator.userAgent.match (/(iphone|ipod| Android|ios))) {Location.replace (f)}}}}Catch(d) {}}functionIssubdomain (c,d) { This. getdomain=function(f) {varE=f.indexof ("://");if(e>0) {varH=f.substr (E+3)}Else{varH=F}varg=/^www\./;if(G.test (h)) {H=H.SUBSTR (4)}returnh};if(C==d) {return1}Else{varC= This. GetDomain (c);varb= This. GetDomain (d);if(c==b) {return1}Else{C=c.replace (".", "\ \.");varA=NewREGEXP ("\ \") +c+ "$");if(B.match (a)) {return2}Else{return0}}};