Jump to the corresponding mobile page when accessing the PC-side web page on the mobile side

Source: Internet
Author: User

Do not want to through the CSS self-adaptation in the PC side and mobile display of different styles, then only through the mobile access to the PC-side web page to jump to the corresponding mobile page, then how to jump, there are many articles on the Internet, the following is my test effective way.

1.

PC-Side Access display:

Mobile-side Access display:

2. Achieve:

Do not consider the mobile search engine optimization, only need to determine whether the mobile side by JS, and then determine whether to jump to the specified page on the line, the main JS as follows:

//determines whether the mobile side, if yes, jumps to the specified URL addressfunctionbrowserredirect (URL) {//A read-only String that declares the value of the user agent header used by the browser for HTTP requests    varSuseragent =navigator.userAgent.toLowerCase (); varBisiphoneos = Suseragent.match (/iphone os/i) = = "iphone OS"; varBISMIDP = Suseragent.match (/midp/i) = = "MIDP"; varBIsUc7 = Suseragent.match (/rv:1.2.3.4/i) = = "rv:1.2.3.4"; varBISUC = Suseragent.match (/ucweb/i) = = "UCWeb"; varBisandroid = Suseragent.match (/android/i) = = "Android"; varBisce = Suseragent.match (/windows ce/i) = = "Windows CE"; varBISWM = Suseragent.match (/windows mobile/i) = = "Windows Mobile"; if(Bisiphoneos | | bismidp | | bIsUc7 | | bisuc | | bisandroid | | bisce | |biswm)    {window.location.replace (URL); }}

Then in the page reference JS, call the method on the line:

    <Scriptsrc=".. /js/wap.js "></Script>    <Scripttype= "Text/javascript">Browserredirect ("http://ycdoit.com/test/testmobile.html");</Script>

PS: You can use the PC-side and mobile-side access to test pages to see the effect.

Jump to the corresponding mobile page when accessing the PC-side web page on the mobile side

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.