Skip to content

Instantly share code, notes, and snippets.

@k9ordon k9ordon/gist:582281 forked from padolsey/gist:527683
Created Sep 16, 2010

Embed
What would you like to do?
// ----------------------------------------------------------
// 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

This comment has been minimized.

Copy link
Owner 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
You can’t perform that action at this time.