Determine the browser version and browser kernel

Source: Internet
Author: User

if (!   browser.ie &&!browser.mac) {var UA = Navigator.userAgent.toLowerCase (). toString (); Determine if the IE kernel is not a non-IE version if (ua.indexof (' 360ee ') >-1) | | (Ua.indexof (' 360se ') >-1) | | (Ua.indexof (' SE ') >-1) | | (Ua.indexof (' aoyou ') >-1) | | (Ua.indexof (' TheWorld ') >-1) | | (Ua.indexof (' Worldchrome ') >-1) | | (Ua.indexof (' Greenbrowser ') >-1) | | (Ua.indexof (' Baidu ') >-1) | | (Ua.indexof (' Qqbrowser ') >-1))       {//is the word Toggle compatibility mode window.open ("publicpage/point-se.aspx");       } else {//No, it is recommended to change the browser alert (' Switch to IE kernel browser '); }} else {//To determine the version model of IE (browser.version = && Browser.ie10compat) | | (browser.version = = && Browser.ie11compat))            {window.open ("publicpage/point.aspx"); }
/* * @desc determine browser version and browser kernel * @author wangyanling * @date July 4, 2014 */var browser = function () {var agent = Navi Gator.userAgent.toLowerCase (), opera = Window.opera, browser = {//detect if the current browser is IE ie:/(msie\s|trident.* RV:) ([\w.] +)/.test (agent),//detect whether the current browser is Opera opera: (!!        Opera && opera.version),//detects if the current browser is the WebKit kernel browser webkit: (Agent.indexof (' applewebkit/') >-1), Detects if the current browser is running on Mac platform Mac: (Agent.indexof (' Macintosh ') >-1),//detect if the current browser is in "weird mode" under quirks:    (Document.compatmode = = ' Backcompat ')}; Detects if the current browser kernel is gecko kernel Browser.gecko = (navigator.product = = ' Gecko ' &&!browser.webkit &&!browser.oper    a &&!browser.ie);    var version = 0; Internet Explorer 6.0+ if (browser.ie) {var v1 = Agent.match (?: msie\s ([\w.]        +))/); var v2 = Agent.match (/(?: Trident.*rv: ([\w.]        +))/);     if (v1 && v2 && v1[1] && v2[1]) {       Version = Math.max (v1[1] * 1, v2[1] * 1);        } else if (v1 && v1[1]) {version = v1[1] * 1;        } else if (v2 && v2[1]) {version = v2[1] * 1;        } else {version = 0;        }//Detect if Browser mode is IE11 compatibility mode Browser.ie11compat = Document.documentmode = = 11;        Detects if the browser mode is IE9 compatibility mode Browser.ie9compat = Document.documentmode = = 9;        Detects if the browser mode is IE10 compatibility mode Browser.ie10compat = Document.documentmode = = 10; Detects if the browser is IE8 browser BROWSER.IE8 =!!        Document.documentmode;        Detects if the browser mode is IE8 compatibility mode Browser.ie8compat = Document.documentmode = = 8; Detects if browser mode is IE7 compatibility mode Browser.ie7compat = ((Version = = 7 &&!document.documentmode) | | document.        Documentmode = = 7);        Detects if browser mode is IE6 mode or weird mode Browser.ie6compat = (Version < 7 | | browser.quirks);        Browser.ie9above = version > 8;    Browser.ie9below = version < 9; }//GecKo. if (Browser.gecko) {var geckorelease = Agent.match (/rv: ([\d\.]        +)/);            if (geckorelease) {geckorelease = Geckorelease[1].split ('. ');        Version = Geckorelease[0] * 10000 + (Geckorelease[1] | | 0) * + (geckorelease[2] | | 0) * 1; }}//detects if the current browser is chrome, and if so, returns the large version number of chrome if (/chrome\/(\d+\.\d)/i.test (agent)) {browser.chrome = +regex    p[' \x241 ']; }//detects if the current browser is safari and, if so, returns the large version of Safari if (/(\d+\.\d)? (?: \). \d)? \s+safari\/? (\d+\.\d+)/i.test (agent) &&!/chrome/i.test (agent)) {Browser.safari = + (regexp[' \x241 ') | |    regexp[' \x242 ');    }//Opera 9.50+ if (browser.opera) Version = Parsefloat (Opera.version ());    WebKit 522+ (Safari) if (browser.webkit) Version = parsefloat (Agent.match (/applewebkit\/(\d+)/) [1]);    Detects the current browser version number browser.version = versions; return browser;} ();

Determine the browser version and browser kernel

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.