1

When I run the following script on Chrome, Firefox and Safari it has no problems detecting itself, but when I run it on IE 11 the console says that IE 11 is Firefox and IE.

function detectBrowser() {
    if ($.browser.mozilla && $.browser.version >= "1.8") {
        console.log("Browser: FireFox");
    }

    if ($.browser.opera) {
        console.log("Browser: Opera");
    }

    if ($.browser.safari) {
        console.log("Browser: Safari");
    }

    if ($.browser.chrome) {
        console.log("Browser: Chrome");
    }

    if ($.browser.msie && $.browser.version <= 6) {
        console.log("Browser: IE (Above v6)");
    }

    if ($.browser.msie && $.browser.version > 6) {
        console.log("Browser: IE (Below v6)");
    }

    if (isIE()) {
        console.log("Browser: IE 11");
    }
}

function isIE() {
    return ((navigator.appName == 'Microsoft Internet Explorer') || ((navigator.appName == 'Netscape') && (new RegExp("Trident/.*rv:([0-9]{1,}[\.0-9]{0,})").exec(navigator.userAgent) != null)));
}

Is IE now under mozilla detection or is my code not completely correct for IE 11 detection?

user229044
  • 232,980
  • 40
  • 330
  • 338
collinhaines
  • 137
  • 2
  • 9

0 Answers0