Skip to content

Instantly share code, notes, and snippets.

@dviramontes
Created September 5, 2013 17:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dviramontes/6453057 to your computer and use it in GitHub Desktop.
Save dviramontes/6453057 to your computer and use it in GitHub Desktop.
$(document).ready(function () {
var iec = new IECompatibility();
alert('IsIE: ' + iec.IsIE + '\nVersion: ' + iec.Version + '\nCompatability On: ' + iec.IsOn);
});
function IECompatibility() {
var agentStr = navigator.userAgent;
this.IsIE = false;
this.IsOn = undefined; //defined only if IE
this.Version = undefined;
if (agentStr.indexOf("MSIE 7.0") > -1) {
this.IsIE = true;
this.IsOn = true;
if (agentStr.indexOf("Trident/6.0") > -1) {
this.Version = 'IE10';
} else if (agentStr.indexOf("Trident/5.0") > -1) {
this.Version = 'IE9';
} else if (agentStr.indexOf("Trident/4.0") > -1) {
this.Version = 'IE8';
} else {
this.IsOn = false; // compatability mimics 7, thus not on
this.Version = 'IE7';
}
} //IE 7
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment