Last active
August 29, 2015 14:25
-
-
Save jamenlyndon/04c8ea13b9bdaecd4b41 to your computer and use it in GitHub Desktop.
Check for IE (JS)
This file contains hidden or 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
// Check for IE | |
// ------------------------------------------------ | |
var ie = (function(){ | |
var undef; | |
var v = 3; | |
var div = document.createElement('div'); | |
var all = div.getElementsByTagName('i'); | |
while ( | |
div.innerHTML = '<!--[if gt IE ' + (++v) + ']><i></i><![endif]-->', | |
all[0] | |
); | |
return v > 4 ? v : undef; | |
}()); | |
// Example usage | |
// ------------------------------------------------ | |
if (ie) { | |
console.log("Rats, they're using IE"); | |
} else if (!ie) { | |
console.log("Hooray, it's not IE!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment