Mobile-side jump and PC-side jump

Source: Internet
Author: User

http://jingyan.baidu.com/article/cdddd41c61823e53cb00e198.html Reference URL

    • Browse:11532
    • |
    • Updated: 2014-04-22 16:51
  1. The first method:

    <script>

    if (navigator.platform.indexOf (' Win32 ')!=-1) {

    Pc

    window.location.href= "Computer website";

    }else{

    Shouji

    window.location.href= "Mobile url";

    }

  2. </script>

  3. 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>

  4. 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>

  5. 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 ();

    }

    ?

  6. 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");

    }

    ?>

  7. 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)

    • Description: Personal advice is to use the method provided by Baidu, simple, convenient, on the website open Speed impact small

experience content is for reference only, if you need to solve specific problems (especially in the areas of law, medicine, etc.), we recommend that you consult the relevant professionals in detail. Reportvote (+) few (0) I have questions (0) Exchange of relevant experience
    • JS Judge mobile phone-side access jump mobile 02016.11.19
    • JavaScript judge access terminal, mobile phone side automatically jump 02015.11.29
    • DEDECMS if the phone accesses the inside page of the computer station? How to jump 02016.11.19
    • JS Judge client IP address jump 02016.05.28
    • JS judge source address and Jump URL02016.09.06
Today's expenditure meta-writing experience money to earn >>sunchongqingpersonality Signature: Crying is no harm to smile always betterAuthor's experience
    • Analysis of the latest medical Network marketing management
    • Weave Dream Safety settings prevent horse hanging
    • Knitting Dream Verification Code does not display
    • Several kinds of introduction ways of medical website commercial Pass
    • Weave Dream Mobile website to build and configure level two domain name
???If you want to complain, please go to Baidu Experience Complaint Center, if you want to put forward comments, suggestions, please go to Baidu Experience Management bar feedback. Personal reprint once again I came across a case
if (navigator.platform.indexOf (' Win32 ')!=-1) {}

Else{window.location.href= "index.html";}

</script>
The key code is this, the ghost eye

Mobile-side jump and PC-side jump

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.