How to find the actual IE browser version, ignoring the document mode that it uses?

1.1k views Asked by At

we want to stop the support for IE8, in order to do that we need to find the browser and version that the client is using (we can do it in client side using navigator.userAgent or in server side [jsp] using the User-Agent header that the client sends with the request).

The problem is that we are forcing the browser to render the pages with the IE8 engine (document mode 8) using the metadata: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8">, so the user will act like an IE 8 browser.

Is there anyway we can find the actual IE version, ignoring the document mode (compatibility mode)?

2

There are 2 answers

1
Debanjan Sharma On

Yes.We can find using JQuery or using Java Script.

To find in Java Script we write :

 function checkBrowserVersion() {

            var ua = window.navigator.userAgent;
            var ie = ua.indexOf("MSIE ");

            if (ie > 0 || !!navigator.userAgent.match(/Trident.*rv\:11\./))    
                alert(parseInt(ua.substring(ie + 5, ua.indexOf(".", ie))));
            else                 
                alert('Other Browser!!');
           return false;
         }

If you want to use Jquery then we can simply use:

if ( $.browser.msie ) {
  alert( $.browser.version );
}

Note:If you are using Jquery version 1.9 or greater than that then you have to include jquery-migrate plugin also. Happy Coding!!!

1
Oday On

I figured a way to do it, we can do it by figuring out the Javascript interpreter version:

var IE = (function () {
        "use strict";
        var ret, isTheBrowser, actualVersion, jscriptMap, jscriptVersion;

        isTheBrowser = false;
        jscriptMap = {"5.5": "5.5", "5.6": "6", "5.7": "7", "5.8": "8", "9": "9", "10": "10", "11": "11"};
        jscriptVersion = new Function("/*@cc_on return @_jscript_version; @*/")();

        if (jscriptVersion !== undefined) {
            isTheBrowser = true;
            actualVersion = jscriptMap[jscriptVersion];
            if (actualVersion === undefined) {
                actualVersion = jscriptVersion;
            }
        } 

        ret = {isTheBrowser: isTheBrowser, actualVersion: actualVersion};

        return ret;
    }());