Skip to content

Instantly share code, notes, and snippets.

@fuhoi
Created June 28, 2011 04:29
Show Gist options
  • Save fuhoi/1050495 to your computer and use it in GitHub Desktop.
Save fuhoi/1050495 to your computer and use it in GitHub Desktop.
javascript-ie-mode
/* JavaScript to determine browser mode */
function getEngine(){
var _eng;
if(window.navigator.appName=="Microsoft Internet Explorer"){ // This is an IE browser. What mode is the engine in?
if(document.documentMode){ // IE8 or later
_eng = document.documentMode;
} else { // IE 5-7
_eng = 5; // Assume quirks mode unless proven otherwise
if(document.compatMode){
if(document.compatMode == "CSS1Compat") {
_eng = 7; // standards mode
}
}
// There is no test for IE6 standards mode because that mode
// was replaced by IE7 standards mode; there is no emulation.
}
// the engine variable now contains the document compatibility mode.
}
return _eng;
} // getEngine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment