"php" Mobile version to access the mobile version of the page select "computer version" and do not go back to the original mobile version of the page, using the session to achieve

Source: Internet
Author: User
Tags php programming
<span id="Label3"></p><p><p>In "javascript" through javascript, if the phone browser access to the PC version of the page, automatically jump to the mobile version of the page (click the open link) in reality, if the user through the mobile phone access to your PC page, automatically jump to the mobile version of the page, but there is a problem, If those mobile phone users see the mobile version of the page, still need to browse the PC version of the page? At this point, they click on the "computer version", because of the role of js, or back to their mobile version of the page to be thrown back.</p></p><p><p>of course, you can say that this is the User's thing, let their mobile browser to change the browsing logo is, but we should write the program more friendly.</p></p><p><p>At this point, you can use php, in fact, jsp,.net,vbscript are the same, because the session object, page condition output in any Web programming language. Here is the example of php, because the PHP programming code is short, everyone can read. Save a user to access the computer version of the Session. In the PC version of the output to jump to the mobile version of the page JS script, first determine whether there is a user to access the computer version of the session, if not, or 0, then jump to the mobile version, the reason to add a 0 judgment, is because some mobile version of the user chose the "computer version" and then select "mobile version", Then select "computer edition", you now the session object has been created, no longer based on the null judgment to output the jump Code.</p></p><p><p><br></p></p><p><p><strong>I. BASIC OBJECTIVES</strong></p></p><p><p>We want to do the following effect, in the case of a browser with similar iphone3gs, the user chooses what version of the page, we give them what Version.</p></p><p><p><br></p></p><p><p><br></p></p><p><p><strong>second, the basic idea</strong></p></p><p><p>For your programming more simple, your mobile version of the page should be set up, if your computer version of the page is called xx.html, then your mobile version of the page should be called ml_xx.html, fill a prefix or suffix and other things to it, easy to redirect Simple. Here is the Ml_ prefix.</p></p><p><p><br></p></p><p><p>is the project page, where ml_pc1.php,ml_pc2.php is the mobile version of the page, pc1.php,pc2.php is the computer version of the page, uaredirect.js is in the "javascript" through the way of javascript, If the phone browser to access the PC version of the page, automatically jump to the mobile version of the page (click the open link), that if the mobile phone access to the PC page, automatically skip the mobile version of the page js. Ml2pc.php and pc2ml.php are our back-end processing Pages.</p></p><p><p><br></p></p><p><p><strong>third, the production process</strong></p></p><p><p>1. pc1.php,pc2.php Computer Edition page</p></p><p><p>pc2.php</p></p><p><p>As described earlier, because to achieve mobile version of the mobile phone version of the page to choose "computer version" after not back to the original mobile page This function, first judge whether there is a user to access the computer version of the session, Then hand over to uaredirect.js to determine whether it is a mobile browser, jump to the corresponding mobile version of the Page. This code is placed on the page header, if you want to jump, you do not have to load the contents of the following PC Page.</p></p><p><p></p></p><pre name="code" class="html"><! DOCTYPE HTML Public "-//w3c//dtd XHTML 1.0 transitional//en" "HTTP://WWW.W3.ORG/TR/XHTML1/DTD/XHTML1-TRANSITIONAL.DTD ">

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.