1. Firefox
Gecko is the Firefox rendering engine. The original gecko was developed as part of a generic Mozilla browser, and the first browser to use the Gecko engine was Netscape6;
We can use the user agent detection: The following JS code:
var ua = navigator.useragent;
Console.log (UA);
Under Windows Firefox, print the following:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) gecko/20100101 firefox/38.0
The above is the composition of the agent string written for Netscape6: as follows:
- Mozilla/mozilla version number (platform; encryption type; operating system or CPU; pre-release version; Gecko/gecko version number; application or product/application or product version number);
2. Safari
Safari's rendering engine is WebKit, a branch of the rendering engine khtml of the Konqueror browser in the Linux platform; a few years later, WebKit became an Open-source project, focused on rendering engine development;
The following code:
var ua = navigator.useragent;
Console.log (UA);
Under Windows Safari, print as follows:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/534.57.2 (khtml, like Gecko) version/5.1.7 safari/534.57.2
The WebKit user Agent string has the following format:
- mozilla/5.0 (platform; encryption type; operating system or CPU) Applewebkit/applewebkit version number (Khtml,like Gecko) Safari/safari version number;
3. Chrome
Google's Chrome browser uses WebKit as its rendering engine, using a different JavaScript engine;
The following JS code:
var ua = navigator.useragent;
Console.log (UA);
Under Windows Chrome, print as follows:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/42.0.2311.152 safari/537.36
The user agent string is completely webkit and only one paragraph is added to indicate the chrome version number, and the format is as follows:
- mozilla/5.0 (platform; encryption type; operating system or CPU) Applewebkit/applewebkit version number (Khtml,like Gecko) chrome/chrome version number Safari/safari version number
4. Opera
Opera's default User agent string is the most reasonable of all modern browsers---correctly identifies its own extreme version number before Opera8.0; its user agent string is in the following format:
- opera/version number (operating system or CPU; encryption type) [language]
- After the Opera8 is published, the language section of the user agent string is moved to parentheses to better match the other browsers, as shown below:
- opera/version number (operating system or CPU; encryption type; language)
In today's latest version of Opera29,
The following JS code:
var ua = navigator.useragent;
Console.log (UA);
The agent detection is as follows:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/42.0.2311.152 safari/537.36;
5. IE
Since IE3, Microsoft has modified IE's user-agent string to a form compatible with Netscape, which is structured as follows:
mozilla/version number (platform; encryption type; operating system or CPU);
However, the ie8+ user agent string adds the version number of the rendering engine (Trident);
The JS code is as follows:
var ua = Navigator.userAgent.toLowerCase ();
Console.log (UA);
For example, under Window IE7 is as follows:
Copy Code code as follows:
mozilla/4.0 (compatible MSIE 7.0; Windows NT 6.1; wow64; trident/7.0;. NET CLR slcc2;. CLR 3.0.30729; Media Center PC 6.0; infopath.3; net4.0c;. net4.0e)
The IE8 are as follows:
Copy Code code as follows:
mozilla/4.0 (compatible MSIE 8.0; Windows NT 6.1; wow64; trident/7.0;. NET CLR slcc2;. CLR 3.0.30729; Media Center PC 6.0; infopath.3; net4.0c;. net4.0e)
But ie9+ has made a little adjustment to the format of the string; The version number of Mozilla has increased to 5.0;
The IE9 are as follows:
Copy Code code as follows:
mozilla/5.0 (compatible MSIE 9.0; Windows NT 6.1; wow64; trident/7.0;. NET CLR slcc2;. CLR 3.0.30729; Media Center PC 6.0; infopath.3; net4.0c;. net4.0e)
The IE10 are as follows:
Copy Code code as follows:
mozilla/5.0 (compatible MSIE 10.0; Windows NT 6.1; wow64; trident/7.0;. NET CLR slcc2;. T CLR 3.0.30729; Media Center PC 6.0; infopath.3; net4.0c;. net4.0e)
The IE11 are as follows:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1; WOW64 trident/7.0; slcc2;. NET CLR 2.0.50727;. NET CLR 3.5.30729;. NET CLR 3.0.30729; Center PC 6.0; infopath.3; net4.0c;. net4.0e; rv:11.0) Like Gecko
6. iOS and Android
Mobile operating systems iOS and Android default browsers are based on WebKit and are all like desktop editions; share the same basic user agent string format; The basic format for iOS devices is as follows:
- mozilla/5.0 (platform; encryption type; operating system or CPU like MAC OS x; language)
- Applewebkit/applewebkit version number (khtml,like Gecko) version/Browser version number
- mobile/Mobile Version number Safari/safari version number
The default format for Android browsers is similar to iOS format, with no mobile version number (but with mobile notation):
- mozilla/5.0 (Linux; U Android 2.2; En-us; Nexus one build/frf91)
- applewebkit/533.1 (khtml, like Gecko) version/4.0 Mobile safari/533.1
7. Konqueror
Konqueror, integrated with KDE Linux, is a browser based on the khtml open source rendering engine. Although Konqueror only
Can be used in Linux, but it also has a significant number of users. To ensure maximum compatibility, Konqueror followed IE selected as
Lower user agent string format:
- mozilla/5.0 (compatible; konqueror/version number; Operating system or CPU)
However, in order to be consistent with the change in the WebKit user agent string, Konqueror 3.2 has changed to the following format
Identify yourself as khtml:
- mozilla/5.0 (compatible; konqueror/version number; Operating system or CPU) khtml/khtml version number (like Gecko)
Here is an example:
Copy Code code as follows:
mozilla/5.0 (compatible; konqueror/3.5; SunOS) khtml/3.5.0 (like Gecko)
User Agent string Detection technology
Identify the rendering engine;
Here we examine the five major rendering engines: Ie,gecko,webkit,khtml and Opera
The following code:
var client = function () {
var engine = {
//render engine
ie:0,
gecko:0,
webkit:0,
khtml:0,
opera:0 ,
//Other version number
ver:null
};
This detects rendering engine, platform and device return
{
engine:engine
};
} ();
In the above client object literal, each rendering engine corresponds to a property whose value defaults to 0, and if the rendering engine is detected, the engine's version number is written to the corresponding property as a floating-point number. The full version of the rendering engine is written to the variable ver attribute;
To correctly identify the rendering engine, the key is to detect the correct sequence, the user agent string There are many inconsistencies, if the detection sequence is not correct, it is likely to lead to incorrect detection results, so the first step is to identify opera, because its user agent string may imitate other browsers The latest version of the Opera browser is 29, so as follows:
var ua = navigator.useragent. toLowerCase ();
Console.log (UA);
Print as follows:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1 WOW64) applewebkit/537.36 (khtml, like Gecko) chrome/42.0.2311.152 safari/537.36 opr/29.0.17 95.60
So the code can be judged as follows:
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/opr\/) ([\d\.] +)/) {
var result = Ua.match (/opr\/([\d\.] +)/);
Console.log (Result)
Console.log (result[1])
}
Implemented as follows:
Console.log (Result), printed as follows:
Copy Code code as follows:
["opr/29.0.1795.60", "29.0.1795.60", index:110, Input: "mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/53...rome/42.0.2311.152 safari/537.36 opr/29.0.1795.60 "];
Console.log (Result[1]) is printed as follows:
Copy Code code as follows:
From this we can write code like this:
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/opr\/) ([\d\.] +)/) {
var result = Ua.match (/opr\/([\d\.] +)/);
Engine.ver = result[1];
Engine.opera = parsefloat (engine.ver);
}
Now let's print down the Console.log (engine), as shown here:
But what about the previous version of Opera29, opera5+ also had Window.opera objects, so we also had to detect Window.opera objects, we could call the version () method to return a string representing the browser version, and the following code:
if (Window.opera) {
engine.ver = window.opera.version ();
Engine.opera = parsefloat (engine.ver);
}
Now we can combine the previous and subsequent opera browsers, as follows:
var engine = client;
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {
var result = Ua.match (/opr\/([\d\.] +)/);
Engine.ver = result[1];
Engine.opera = parsefloat (engine.ver);
if (Window.opera) {
engine.ver = window.opera.version ();
Engine.opera = parsefloat (engine.ver);
}
}
Now the second step is to detect the engine is WebKit, because WebKit's user agent string contains "Gecko" and "khtml" these two strings, if the detection of these two, there may be errors, but the WebKit user agent string "AppleWebKit" is unique, so it can be detected according to this;
var engine = client;
var ua = Navigator.userAgent.toLowerCase ();
if (/applewebkit\/(\s+)/.test (UA)) {
Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver);
}
So the combination of all the above code is as follows:
var engine = client;
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {
var result = Ua.match (/opr\/([\d\.] +)/);
Engine.ver = result[1];
Engine.opera = parsefloat (engine.ver);
if (Window.opera) {
engine.ver = window.opera.version ();
Engine.opera = parsefloat (engine.ver);
}
} else if (/applewebkit\/(\s+)/.test (UA)) {
Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver);
}
The next rendering engine to be tested is khtml, which also contains "Gecko" in the Khtml user agent string, so we cannot accurately detect the Gecko based browser before excluding khtml. The khtml version number is the same as the WebKit version number in the user agent string, so you can also use regular expressions, and because Konqueror 3.1 and earlier versions do not contain khtml versions, you will use the Konqueror version instead. The following is the corresponding detection code.
if (/khtml\/(\s+)/.test (UA) | |/konqueror\/([^;] +)/.test (UA)) {
Engine.ver = regexp["$"];
engine.khtml = parsefloat (engine.ver);
}
Here's all the code:
var engine = client;
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {
var result = Ua.match (/opr\/([\d\.] +)/);
Engine.ver = result[1];
Engine.opera = parsefloat (engine.ver);
if (Window.opera) {
engine.ver = window.opera.version ();
Engine.opera = parsefloat (engine.ver);
}
} else if (/applewebkit\/(\s+)/.test (UA)) {
Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver);
} else if (/khtml\/(\s+)/.test (UA) | |/konqueror\/([^;] +)/.test (UA)) {
Engine.ver = regexp["$"];
engine.khtml = parsefloat (engine.ver);
}
After the WebKit and khtml are excluded, the Gecko can be detected accurately, but in the user agent string, the Gecko version number does not appear after the string "Gecko", but appears after the string "rv:". Therefore, a more complex regular expression must be used;
For example, the user agent under Firefox is as follows:
Copy Code code as follows:
mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) gecko/20100101 firefox/38.0
The following JS code detection:
var engine = client;
var ua = Navigator.userAgent.toLowerCase ();
if (/RV: ([^\)]+) \) gecko\/\d{8}/.test (UA)) {
Engine.ver = regexp["$"];
Engine.gecko = parsefloat (engine.ver);
}
So all the JS code is as follows:
var engine = client;
var ua = Navigator.userAgent.toLowerCase ();
if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {
var result = Ua.match (/opr\/([\d\.] +)/);
Engine.ver = result[1];
Engine.opera = parsefloat (engine.ver);
if (Window.opera) {
engine.ver = window.opera.version ();
Engine.opera = parsefloat (engine.ver);
}
} else if (/applewebkit\/(\s+)/.test (UA)) {
Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver);
} else if (/khtml\/(\s+)/.test (UA) | |/konqueror\/([^;] +)/.test (UA)) {
Engine.ver = regexp["$"];
engine.khtml = parsefloat (engine.ver);
} else if (/rv: ([^\)]+) \) gecko\/\d{8}/.test (UA)) {
Engine.ver = regexp["$"];
Engine.gecko = parsefloat (engine.ver);
}
The last detection is IE browser, the version number of IE is located in the string "MSIE" behind, a semicolon in front of the following:
Copy Code code as follows:
mozilla/5.0 (compatible MSIE 9.0; Windows NT 6.1; wow64; trident/7.0;. NET CLR slcc2;. CLR 3.0.30729; Media Center PC 6.0; infopath.3; net4.0c;. net4.0e)
The following JS code detection:
if (/msie) ([^;] +)/.test (UA)) {
Engine.ver = regexp["$"];
engine.ie = parsefloat (engine.ver);
}
As above; All the code is as follows:
var client = function () {var engine = {//render engine ie:0, gecko:0, webkit:0, khtml:0, opera:0,
Other version number Ver:null};
This detects rendering engine, platform and device return {engine:engine};
}();
var engine = client;
var ua = Navigator.userAgent.toLowerCase (); if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {var result = Ua.match (/opr\/([\d\.]
+)/);
Engine.ver = result[1];
Engine.opera = parsefloat (engine.ver);
if (window.opera) {engine.ver = Window.opera.version ();
Engine.opera = parsefloat (engine.ver);
}}else if (/applewebkit\/(\s+)/.test (UA)) {Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver); }else if (/khtml\/(\s+)/.test (UA) | |/konqueror\/([^;]
+)/.test (UA)) {Engine.ver = regexp["$"];
engine.khtml = parsefloat (engine.ver);
}else if (/rv: ([^\)]+) \) gecko\/\d{8}/.test (UA)) {Engine.ver = regexp["$"];
Engine.gecko = parsefloat (engine.ver); }else if (/msie) ([^;]
+)/.test (UA)) {Engine.ver = regexp["$"]; engine.ie = ParsefLoat (Engine.ver);
}
Identifying browsers
In most cases, such as the above identified engine is not enough to meet our needs, such as Apple's Safari browser and Google's Chrome browser are using WebKit as the rendering engine; But their JavaScript engine is different, in both browsers, Client.webkit will return a value of not 0, can not distinguish, so we also need to identify the browser;
Add the following code as follows:
var client = function () {
var engine = {
//render engine
ie:0,
gecko:0,
webkit:0,
khtml:0,
opera:0 ,
//Other version number
ver:null
};
var browser = {
//browser
ie:0,
firefox:0,
safari:0, konq:0, opera:0,
chrome:0,
//Other version
ver:null
};
This detects rendering engine, platform and device return
{
engine:engine,
browser:browser
};
();
As the code above adds a private variable browser, which holds the properties of each major browser, as with the engine variable, the other property values remain at 0, except for the browser currently in use, and in the case of the current browser, this property holds the version number in floating-point numbers. The Ver attribute in the same browser will contain the full version number of the browser, if necessary, in the form of a string;
So all the JS code after encapsulation is as follows:
var client = function () {var engine = {//render engine ie:0, gecko:0, webkit:0, khtml:0, opera:0,
Other version number Ver:null};
var browser = {//browser ie:0, firefox:0, safari:0, konq:0, opera:0, chrome:0,//other version
Ver:null};
This detects rendering engine, platform and device return {engine:engine, browser:browser};
}();
var engine = client;
var browser = client;
var ua = Navigator.userAgent.toLowerCase (); if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {var result = Ua.match (/opr\/([\d\.]
+)/);
Engine.ver = Browser.ver = Result[1];
Engine.opera = Browser.opera = parsefloat (engine.ver);
if (window.opera) {engine.ver = Browser.ver = Window.opera.version ();
Engine.opera = Browser.opera = parsefloat (engine.ver);
}}else if (/applewebkit\/(\s+)/.test (UA)) {Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver); Make sure it's Chrome or safari/* Chrome user Agent String * mozilla/5.0 (Windows NT 6.1; WOW64) Applewebkit/537.36 (khtml, like Gecko) * chrome/42.0.2311.152 safari/537.36/if (/chrome\/(\s+)/.test (UA)) {Browser
. ver = regexp["$";
Browser.chrome = parsefloat (browser.ver); }else if (/version\/(\s+)/.test (UA) {* * Safari user Agent String * mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/534.57.2 (khtml, like Gecko) * version/5.1.7 safari/534.57.2/browser.ver = regexp["$
"];
Browser.safari = parsefloat (browser.ver);
}else {//approximately determines the version number var safariversion = 1;
if (Engine.webkit < MB) {safariversion = 1;
else if (Engine.webkit < 312) {safariversion = 1.2;
else if (Engine.webkit < 412) {safariversion = 1.3;
else {safariversion = 2;
} Browser.safari = Browser.ver = safariversion; }}else if (/khtml\/(\s+)/.test (UA) | |/konqueror\/([^;]
+)/.test (UA)) {engine.ver = Browser.ver = regexp["$"];
engine.khtml = Browser.konq = parsefloat (engine.ver); }else if (/rv: ([^\)]+)\) Gecko\/\d{8}/.test (UA)) {Engine.ver = regexp["$"];
Engine.gecko = parsefloat (engine.ver); * * Firefox user agent String * mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) * gecko/20100101 firefox/38.0//Determine if the Firefox if (/firefox\/(\s+)/.test (UA)) {Browser
. ver = regexp["$";
Browser.firefox = parsefloat (browser.ver); }else if (/msie ([^;] +)/.test (UA) | | ' ActiveXObject ' in window ' {if (' ActiveXObject ' in window) {if (/msie (^;] +)/.test (UA)) {engine.ver = Browser.ver = regexp["1"]; engine.ie = browser.ie = parsefloat (engine.ver); }else {//ie11+ if (/rv: ([^\)]+) \)/.test (UA)) {engine.ver = Browser.ver = regexp["1"]; engine.ie = browser.ie = parsefloat (engine.ver);
}else {//ie11+ if (/rv: ([^\)]+) \)/.test (UA)) {engine.ver = Browser.ver = regexp["1"];
engine.ie = browser.ie = parsefloat (engine.ver);
The next Console.log (browser) can be printed;
For opera and IE, the value in the browser object is equal to the value in the Engine object, browser for Konqueror.
The Konq and Browser.ver properties are equal to the engine.khtml and Engine.ver properties, respectively. To detect chrome and safari, we added an if statement to the code of the detection engine. When extracting the chrome version number, you need to find the string "chrome/" and get the numeric value that follows the string. When you extract the version number of Safari, you need to find the string "version/" and get the values that followed. Since this is only true for Safari 3 and later, you'll need some extra code to approximate the version number of WebKit to the version number of Safari (not much for else). When you detect a Firefox version, you first find the string "firefox/" and then extract the values that follow the string.
With the above code, we can write the following code to determine the following code:
">" "> if (Client.engine.webkit) {//if it ' s webkit if (client.browser.chrome) {//execute for CH Rome Code} else if (Client.browser.safari) {//Execute code for Safari} or else if (Client.engine.gecko) {if client.brows Er.firefox) {//execute Firefox code} else {//execute code for other gecko browsers}} The identification platform currently has three major platforms (Windows,mac,unix including various Lin
UX), because those browsers (SAFARI,OPERA,FIREFOX) may have different problems on different platforms; To detect these platforms, you need to add a new object as follows; var client = function () {var engine = {
Render engine ie:0, gecko:0, webkit:0, khtml:0, opera:0,//other version number Ver:null};
var browser = {//browser ie:0, firefox:0, safari:0, konq:0, opera:0, chrome:0,//other version
Ver:null};
var system = {Win:false, mac:false, xll:false};
This detects rendering engine, platform and device return {engine:engine, browser:browser, System:system};
}();
The code above adds a new variable system that contains 3 properties, where the Win property indicates whether it is a Windows platform, and the Mac represents the property of the object that MAC,XLL represents is the default of false, and when the platform is determined, the Unix,system Detecting navigator.platform is simpler than detecting user agent strings, and detecting user agent strings gives different platform information in different browsers, while the possible values for Navigator.platform properties include "Win32", "Win64", " MacPPC "," Macintel "," Xll "and" Linux i686 ", these values are consistent in different browsers, the detection code is very intuitive, the following code:
var system = client;
var platform = Navigator.platform;
System.win = Platform.indexof ("win") = = 0;
System.mac = Platform.indexof ("mac") = = 0;
system.x11 = (Platform.indexof ("X11") = = 0) | | (Platform.indexof ("Linux") = = 0);
For example, I now print the following in the Chrome browser:
Screenshot below:
If I want to know if it's Win32 or Win64, we can use this code to print.
Console.log (Navigator.platform);
Identify mobile devices
You can set the value of the response property individually by simply detecting the string "IPhone", "IPod", and "IPad".
System.iphone = Ua.indexof ("iphone") >-1;
System.ipod = Ua.indexof ("ipod") >-1;
System.ipad = Ua.indexof ("ipad") >-1;
- In addition to knowing the iOS device, it's best to know the version number of iOS. Prior to iOS 3, the user agent string contained only "CPU like
- Mac OS ", and then the iphone is changed to" CPU iphone OS 3_0 like Mac os X ", the IPad is changed to" CPU OS 3_2
- Like Mac OS X ". In other words, detecting iOS requires regular expressions to reflect these changes.
Detect iOS version
if (System.mac && ua.indexof ("mobile") >-1) {
if/cpu (?: iphone)? OS (\d+_\d+)/.test (UA)) {
System.ios = parsefloat (Regexp.$1.replace ("_", "."));
} else {
System.ios = 2;//////cannot be really detected, so only guess
}
}
- Check to see if the system is Mac OS, or if there is a "Mobile" in the string, to ensure that no matter what version it is, System.ios
- None of them will be 0. Then, use the regular expression to determine if there is an iOS version number. If so, set the System.ios to
- A floating-point value that represents the version number, otherwise the version is set to 2. (because there is no way to determine exactly what version, so set to the earlier
- The version is more secure. )
- Detection of the Android operating system is also very simple, that is, the search string "Android" and get the version number immediately following.
Detect Android version
if (/android (\d+\.\d+)/.test (UA)) {
system.android = parsefloat (regexp.$1);
}
- Since all versions of Android have version values, this regular expression can accurately detect all versions and
- System.android is set to the correct value.
- On the basis of understanding these device information, you can use the following code to determine what device the user is using WebKit to
To access a Web page:
if (client.engine.webkit) {
if (client.system.ios) {
//ios the contents of the phone
} else if (client.system.android) {
Android phone's content
}
}
So all the JS code is as follows:
var client = function () {var engine = {//render engine ie:0, gecko:0, webkit:0, khtml:
0, opera:0,//other version number Ver:null}; var browser = {//browser ie:0, firefox:0, safari:0, konq:0, opera:0, Chrom
e:0,//other version ver:null}; var system = {Win:false, mac:false, Xll:false,//mobile device Iphone:false, ipod:
False, Ipad:false, Ios:false, android:false};
This detects rendering engine, platform and device return {engine:engine, browser:browser, System:system};
}();
var engine = client;
var browser = client;
var ua = Navigator.userAgent.toLowerCase (); if (Ua.match (/opr\/) ([\d\.] +)/) || Window.opera) {var result = Ua.match (/opr\/([\d\.]
+)/);
Engine.ver = Browser.ver = Result[1];
Engine.opera = Browser.opera = parsefloat (engine.ver); IfWindow.opera) {engine.ver = Browser.ver = Window.opera.version ();
Engine.opera = Browser.opera = parsefloat (engine.ver);
}}else if (/applewebkit\/(\s+)/.test (UA)) {Engine.ver = regexp["$"];
Engine.webkit = parsefloat (engine.ver); Make sure it's Chrome or safari/* Chrome user Agent String * mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/537.36 (khtml, like Gecko) * chrome/42.0.2311.152 safari/537.36/if (/chrome\/(\
s+)/.test (UA)) {Browser.ver = regexp["$"];
Browser.chrome = parsefloat (browser.ver); }else if (/version\/(\s+)/.test (UA) {* * Safari user Agent String * mozilla/5.0 (Windows NT 6.1; WOW64) applewebkit/534.57.2 (khtml, like Gecko) * version/5.1.7 safari/534.57.2/BROWSER.V
ER = regexp["$"];
Browser.safari = parsefloat (browser.ver);
}else {//approximately determines the version number var safariversion = 1; if (engine. WebKit <) {safariversion = 1;
else if (Engine.webkit < 312) {safariversion = 1.2;
else if (Engine.webkit < 412) {safariversion = 1.3;
else {safariversion = 2;
} Browser.safari = Browser.ver = safariversion; }}else if (/khtml\/(\s+)/.test (UA) | |/konqueror\/([^;]
+)/.test (UA)) {engine.ver = Browser.ver = regexp["$"];
engine.khtml = Browser.konq = parsefloat (engine.ver);
}else if (/rv: ([^\)]+) \) gecko\/\d{8}/.test (UA)) {Engine.ver = regexp["$"];
Engine.gecko = parsefloat (engine.ver); * * Firefox user agent String * mozilla/5.0 (Windows NT 6.1; WOW64;
rv:38.0) * gecko/20100101 firefox/38.0//Determine whether Firefox if (/firefox\/(\s+)/.test (UA)) {
Browser.ver = regexp["$"];
Browser.firefox = parsefloat (browser.ver); }else if (/msie ([^;] +)/.test (UA) | | "ActiveXObject' In Window ' {if (' ActiveXObject ' in window) {if (/msie) ([^;]
+)/.test (UA)) {engine.ver = Browser.ver = regexp["$"];
engine.ie = browser.ie = parsefloat (engine.ver);
}else {if (/rv: ([^\)]+) \)/.test (UA)) {engine.ver = Browser.ver = regexp["$"];
engine.ie = browser.ie = parsefloat (engine.ver);
}}//detection platform var system = client;
var platform = Navigator.platform;
System.win = Platform.indexof ("win") = = 0;
System.mac = Platform.indexof ("mac") = = 0; system.x11 = (Platform.indexof ("X11") = = 0) | |
(Platform.indexof ("Linux") = = 0);
Mobile device System.iphone = Ua.indexof ("iphone") >-1;
System.ipod = Ua.indexof ("ipod") >-1;
System.ipad = Ua.indexof ("ipad") >-1; Detect iOS version if (System.mac && ua.indexof ("mobile") >-1) {if/CPU (?: iphone)/.test (UA ) {System.ios =Parsefloat (Regexp.$1.replace ("_", ".")); else {System.ios = 2;//cannot be really detected, so can only guess}//detect Android Version if (/android (\d+\.\d+)/.test (UA))
{system.android = parsefloat (regexp.$1);
}