Determine client devices and browsers types according to the characteristics of

Recommended for you: Get network issues from WhatsUp Gold. Not end users.
The writing is too great, the direct transfer
The original link:



The above "Web compatibility development series of articles (a): different equipment browser userAgent value Daquan" lists commonly used computer browser and intelligent mobile phone browser userAgent value

Here to do a analysis on userAgent characteristics of their own browser, and gives the method to judge the:


Windows Operating System Explorer Series:


    The IE browser series:
    Features: all begins with "mozilla/", "MSIE x.0;" x said its version,
    Method: rough judgment can only search for "MSIE x.0;" string, strict judgment can search "mozilla/x.0 (compatibal; MSIE x.0; Windows NT", but usually it is not necessary
    Windows version of the Firefox:
    Features: start with "mozilla/x.0", "Windows NT", including "gecko/" and"firefox/" ,
    Method: rough judgment can only search for "firefox/" and "Windows NT" string, strict judgment can search for "mozilla/", "Windows NT", "gecko/" and "firefox/" four strings,
    Windows version of the Chrome:
    Features: start with "mozilla/x.0", "Windows NT", including "chrome/", also contains"applewebkit/","safari/",
    Method: rough judgment can only search for "Windows NT" and "chrome/" string, strict judgment can also search for "mozilla/", "Windows NT", "applewebkit/", "safari/", "chrome/" five strings,
    Windows version of the Opera:
    Features: start with "opera/", "Windows NT", containing the string "presto/",
    Method: rough judgment to retrieve only the "Windows NT" and "opera/" string, strict judgment also search for "opera/", "windows and NT" "presto/",
    Windows version of the Safari:
    Features: start with "mozilla/", also contain"windows nt","applewebkit/","safari/",
    Method: rough judgment can be retrieved with "Windows NT", "safari/" also does not contain "chrome/", strict judgment need also contains "mozilla/", "Windows NT", "applewebkit/", "safari/" but not included"chrome/",
    Summary: the Windows operating system on the browser userAgent contains "Windows NT" string to the characterization of Windows operating system.



The iPhone Platform Browser series:

    IPhone comes with Safari:
    Features: start with "mozilla/", "iPhone" string containing, also contains "mobile/", "safari/" string,
    Method: rough judgment to retrieve only the "iPhone" and "safari/" string, strict judgment should also include "mozilla/", "iPhone", "mobile/", "safari/" four strings
    The iPhone version of Opera Mobile:
    Features: start with "opera/", "iPhone" contains the string, "opera mini/," also contains the string "presto/",
    Method: rough judgment to retrieve only the "iPhone" and "opera/" string, strict judgment should also include "opera/", "iPhone", "opera mini/", "presto/" four strings
    Summary: iPhone mobile phone browser userAgent contains the string "iPhone"



The Android Platform Browser series:

    Android browser (some people say that is chrome, but Google itself did not run, and also the development of a Android Chrome to Phone):
    Features: start with "mozilla/", with "Android" and "Linux" string, "applewebkit/", with "mobile safari/" string,
    Method: because do not know Android will have a separate Safari (estimates not), so that strict judgment, search for "mozilla/", "Android", "Linux", "applewebkit/", "mobile safari/" five strings
    The Android version of Opera Mobile:
    Features: start with "opera/", with "Android" and "Linux" string, containing both "opera mobi/", "presto/" string,
    Method: rough judgment to retrieve only the "Android" and "opera/", strict judgment should also include "opera/", "Android", "Linux", "opera mobi/", "presto/" five strings
    Android version of the Firefox:
    Features: start with "mozilla/", with "Android" and "Linux" string, also contains "firefox/", "gecko/", "fennec/" string,
    Method: rough judgment to retrieve only the "Android" and "firefox/", strict judgment should also include "mozilla/", "Android", "Linux", "firefox/", "gecko/", "fennec/" six strings
    Summary: on the platform of Android browser userAgent contains "Android" and "Linux" string



      The windows, iPhone, Android three platform mainstream browser analytical basic ended, other platform Linux estimation with at least Android platform should be similar, and the use of the Mac OS iPad and Macintosh should be similar with the iPhone platform, so temporarily not analytical, also do not have so much equipment and operating system. Test, hope to fill.


      Product development now requirements are not the same as before, because not only to meet the computer browsing, but also needs to satisfy the users through intelligent mobile phone (here refers only to iPhone, Android, Windows Phone and other real intelligent mobile phone, blackberry and palm such small semi intelligent system not to consider, as the Symbian pseudo intelligent system Get out of my way through it) more than three representative platform, also can be roughly estimated according to the browser userAgent solutions user equipment.


1, If you need to determine the operating system, a relatively simple method, the following string search in userAgent:

    With "Windows NT": obviously, windows operating system, NT version number can judge the OS version,
    Contains "Mac": Apple's Mac OS system X or other Mac OS kernel,
    Contains "iPhone": the Apple iPhone mobile phone proprietary, should also contain a general"mac",
    Contains "iPad": Apple's iPad tablet computer (data shows that the iPad browser userAgent also contains"mac","iphone","ipad"),
    Contains "Linux":Linux operating system or other uses Linux as the operating system kernel,
    Contains "Android": Android operating system Google, there may be a smart mobile phone, there may be a tablet computer Android version of Oh, general Android platform userAgent should also be included"linux",
    With "UNIX", "SunOS", "BSD" one of the three systems: Unix, in fact for the system's user experience, now almost can not consider.,
    "Ubuntu" contains a customized version of the:ubuntu Linux
    ...

As you can see, judge the operating system and version is not always useful, but some can be used to place, for example, developed specifically for iPhone, iPad, Android and other equipment screen resolution page


2, Judging the browser kernel, method is not difficult, I figured it out, do not have to.:

    IE(Trident)The kernel (IE for Mac, IEs4Linux, needless to say, only consider windows): beginning with "mozilla/", with "Windows NT" and "MSIE" string,
    Firefox(Gecko)Kernel: beginning with "mozilla/", is containing "firefox/" and "gecko/" string, which version of the Android with the string "fennec/",
    Opera()Kernel: beginning with "opera/", "presto/" contains the string, the iPhone version is also provided with a "opera mini/", Android also with"opera mobi/",
    The Webkit kernel: beginning with "mozilla/", with "applewebkit/" and "safari/" with "chrome/" string, which is the Chrome browser, without Safari or other,
    Above is the major browser kernel.

      The browser kernel is the key to solve the problems of compatibility, however, the compatibility problem has jQuery and Extjs framework to help you solve, so the judge only for individual pages of CSS style to use, in different kernel rendering case of course, the same kernel in the intelligent mobile phone and computer and other devices the rendering results are different, this also need to pay attention to.


3, For example, the practical application of the browser useAgent judgment:

    Different rendering effects of different browser kernel on the page, although there are jQuery and Extjs compatible for us to do, but there are still some small difference we need to separate processing, the need to determine whether the browser kernel,
    The user is not only access the site through the computer., Intelligent mobile phone with the increasing popularity of computer and the popularity of tablet, The use of both the Internet increasingly high proportion, What am I gonna do? Tablet computer., Large screen and high resolution, Intelligent mobile phone is limited by his screen size and resolution, Although the processing ability strong, Also can be the perfect support for existing sites, But for many customers consider the point won't hurt you to say? After all, the local scaling drag way to look at the Webpage very uncomfortable, At this time., We can specifically narrow screen for iPhone, Android provides a special version of the layout of the, To enhance the browsing experience, To reduce network traffic, Speed up access,
    Do visitors flow analysis, through judging whether the client browser type and record the number, to optimize the design of your own website, to enhance the customer experience
    ...
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download

Posted by Basil at December 17, 2013 - 10:48 PM