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.