The front end determines whether the user request is a PC or a mobile end

Source: Internet
Author: User

Links: https://www.zhihu.com/question/20004700/answer/13678113
  • The first step in the server-side using the user agent to determine, first match the mobile device, this step can be counted the user agent list (can be obtained through the website access log or use their own device collection), write the matching device of the regular expression (such as the Iphone/touch series of matching rules is /iphone os/i, if you want to fit the system version number, the rules will be more complex), according to the matching results to do the corresponding site version output.
    Note that the smartphone in the mobile Cmwap access mode user-agent will be filtered by the gateway, so in the first step of the server side to determine the UA can then be in the browser side of the server to obtain access to the UA device using JavaScript two times to judge.
  • There are three ways to match the results according to the first step:
    A. Jump to a different URL and maintain the three sites separately (example: Facebook, major domestic portals)
    B. Use different page template output pages for different devices (example: Deviantart, TUMBLR) on the same web site
    C. Use only a set of front-end display, to the various devices to do a centralized adaptation (UI layout of the adaptive, front-end technology integrated compatibility, Example:/http/cubiq.org)
    The first two ways of high back-end maintenance costs, suitable for mobile and PC-side product content patterns of different situations, the third approach for the consistency of the platform content, back-end maintenance costs are small, but the front-end technology and UI layout requirements are very high.
  • See the solutions above

The front end determines whether the user request is a PC or a mobile end

Related Article

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.