-
-
Save k9ordon/582281 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ---------------------------------------------------------- | |
// 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); | |
}()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if(!ie) { alert ('IE is Kryptonite.'); }