Last active
October 14, 2017 13:14
-
-
Save devheedoo/a4a1fe2208d6b93ef7c5b1e90f4ef61d to your computer and use it in GitHub Desktop.
Total IE Detection using conditional comments (<10) and JavsScript (10, 11)
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
<!-- Tested on 2016. 12. 5. --> | |
<body> | |
<!-- IE8 --> | |
<!--[IF IE 8]> | |
<p>isIE8</p> | |
<![endif]--> | |
<!-- IE9 --> | |
<!--[IF IE 9]> | |
<p>isIE9</p> | |
<![endif]--> | |
<!-- Conditional Comment no longer works since IE10 --> | |
<!-- So we use JavaScript --> | |
<div id="isIE10"></div> | |
<div id="isIE11"></div> | |
<script> | |
$(document).ready(function() { | |
// IE10 | |
if (Function('/*@cc_on return document.documentMode===10@*/')()) { | |
console.log('IE10'); | |
$('#isIE10').append('<p>IE10</p>'); | |
} | |
// IE11 | |
if (/Trident.*rv[ :]*11\./.test(navigator.userAgent)) { | |
console.log('IE11'); | |
$('#isIE11').append('<p>IE11</p>'); | |
} | |
}); | |
</script> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment