Skip to content

Instantly share code, notes, and snippets.

@devheedoo
Last active October 14, 2017 13:14
Show Gist options
  • Save devheedoo/a4a1fe2208d6b93ef7c5b1e90f4ef61d to your computer and use it in GitHub Desktop.
Save devheedoo/a4a1fe2208d6b93ef7c5b1e90f4ef61d to your computer and use it in GitHub Desktop.
Total IE Detection using conditional comments (<10) and JavsScript (10, 11)
<!-- 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