Last active
May 11, 2024 15:22
-
-
Save julianshapiro/9098609 to your computer and use it in GitHub Desktop.
Future-Proof IE Version Detection Without User Agent Sniffing
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
var IE = (function() { | |
if (document.documentMode) { | |
return document.documentMode; | |
} else { | |
for (var i = 7; i > 4; i--) { | |
var div = document.createElement("div"); | |
div.innerHTML = "<!--[if IE " + i + "]><span></span><![endif]-->"; | |
if (div.getElementsByTagName("span").length) { | |
div = null; | |
return i; | |
} | |
} | |
} | |
return undefined; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment