PrefaceUsually when making h5 pages, you need to do some traffic diversion work within the WeChat, QQ, Weibo and other ecosystems, but the traffic diversion is limited by these platforms. For example, the last article "h5 wake-up app implementation and points to note" is a compromise. So what are the User Agents of these commonly used browsers like? How to judge? Let’s take a closer look at this issue today. User Agent DefinitionUser Agent is the Chinese name for User Agent, abbreviated as UA. It is a special string header that enables the server to identify the operating system and version, CPU type, browser and version, browser rendering engine, browser language, browser plug-ins, etc. used by the client. ---From Baidu Encyclopedia From this sentence, we can know that we can obtain information such as the operating system and version, CPU type, browser and version used by the user through UA, right? Several common browser UAOnly WeChat, Weibo, QQ and other browsers are obtained here. The rest are not obtained yet. If you have any additions, please send a private message or leave a comment. Android The Android version currently used is Huawei Honor V9 Play, the current Android system version is 7.0 and the EMUI version is 5.1. QQ Browser
apple Apple currently uses iPhone 6s Plus, and the current iOS version is 12.4. QQ Browser
All the above UA values are processed by toLowerCase, so they are all lowercase. Determine several commonly used browsers separatelyBefore judging, you need to do an operation on UA, which is to convert all letters into lowercase, which can be achieved through toLowerCase, and then judge them separately. It is actually very easy to judge through the above UAs. There is already a way to write this in the last article, as follows: /micromessenger/i.test(u) // Check WeChat u.indexOf("weibo") > -1 // Check Weibo u.indexOf("qq") > -1 // Check QQ u.indexOf("mqqbrowser") > -1 // Determine QQ browser Note that QQ requires a space before qq. Get additional informationIt is not difficult to see from the above UA that the current system can be determined by UA, whether it is Android or iOS, which can be distinguished by the following code: /android/i.test(UA) //Judge Android /(iPhone|iPad|iPod|iOS)/i.test(UA) //Judge iOS The above data also shows the specific type of mobile phone, which I will not introduce in detail here. In addition, many mobile browsers can change UA, such as Quark and UC. If you study it in depth, you can get more information. SummarizeThis concludes this article on how JavaScript can determine several commonly used browsers through userAgent. For more relevant JS userAgent browser determination content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: mysql code to implement sequence function
>>: How to implement MySQL master-slave replication based on Docker
Online shopping mall database-product category da...
Add rules to the el-form form: Define rules in da...
CSS3 Patterns Gallery This CSS3 pattern library s...
Table of contents Problem Description Method 1 (b...
Detailed explanation of MySQL instance with SSD s...
1. Idea It only took 6 seconds to insert 1,000,00...
Pull the image: [mall@VM_0_7_centos ~]$ sudo dock...
In Black Duck's 2017 open source survey, 77% ...
Preface This experiment prepares two virtual mach...
After the form input box input is set to the disa...
Pop-up windows are often used in actual developme...
AI image cutting needs to be coordinated with PS....
1. MySQL gets the current date and time function ...
In the past few years, DIV+CSS was very popular in...
Assume there is such an initial code: <!DOCTYP...