About the Web page JS to determine the "client device type is mobile or PC-side" solution? __ Mobile Phone

Source: Internet
Author: User
JS in the Web page how to determine whether the device type is mobile or PC end. sometimes in the project encountered equipment type judgment problem, here and you share a JS Judge device type method;

This method not only solves the problem of the device type, but also can change the link of the Web page directly according to the device type.

When it comes to device type judgments, here's the HTML DOM useragent attribute. In simple terms, the UserAgent property is a read-only string that declares the value of the user agent header used by the browser for HTTP requests. value of the UserAgent property

In general, it is formed after the value of the Navigator.appcodename plus a slash and a navigator.appversion value. For more information, please refer to the definitions in [the "the"], and we will not do any in-depth research here. In addition, you can view the various browser useragent list (desktop + mobile) to understand the differences between different devices. code block

The following is in the work, after continuous study and research, I summed up the best results, basically can meet the medium needs of the project:

<! DOCTYPE html>  

It is recommended that you not only simulate the phone effect in the computer segment.

The above is "about JS to determine the type of equipment," all the content, welcome everyone to test the verification, comments, I will see the first time in a timely response.

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.