Skip to content

Instantly share code, notes, and snippets.

@k9ordon
Forked from padolsey/gist:527683
Created September 16, 2010 11:21
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 k9ordon/582281 to your computer and use it in GitHub Desktop.
Save k9ordon/582281 to your computer and use it in GitHub Desktop.
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// if (ie) { alert('IE ' + ie); } // else ie version is not a number;
// if(!ie) { alert ('IE is Kryptonite.'); }
var ie = (function(){
var div = document.createElement('div');
for (v=6;v<=9;v++)
div.innerHTML += '<!--[if IE ' + v + ']>' + v + '<![endif]-->'
return parseInt(div.innerHTML);
}());
@k9ordon
Copy link
Author

k9ordon commented Sep 16, 2010

if(!ie) { alert ('IE is Kryptonite.'); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment