Showing posts with label IE compatibility JavaScript. Show all posts
Showing posts with label IE compatibility JavaScript. Show all posts

Friday, October 30, 2015

Detect IE compatibility mode and version using JavaScript

Even though it is not recommended, following Javascript can be used to detect the IE compatibility mode.


// Create new object

var ieUserAgent = {
init: function () {
 
var ua = navigator.userAgent;
this.compatibilityMode = false;

    if(ua.indexOf("MSIE") == -1){
        this.version = 0;
        return 0;
    }

    if(ua.indexOf("compatible") == -1){
        this.compatibilityMode = false;
        return 0;

    }else{
        this.compatibilityMode = true;
        return 0;
    }
}
};

// Initialize the ieUserAgent object
ieUserAgent.init();

Read this thread for more details of the script.

Cheers,
Samitha