Kunok Kunok - 11 months ago 55
HTML Question

If IE tag not working as expected

I have this HTML

<script>
internet_explorer = false;
</script>
<!--[if IE]>
<script type="text/javascript">
internet_explorer = true;
</script>
<![endif]-->


and this JS:

console.log(internet_explorer)


When I run this on all browsers it should be false and it is. However, it is supposed to be true on Internet Explorer but it's false. What do I do wrong?

Answer Source

Conditional comments are no longer supported

Support for conditional comments has been removed in Internet Explorer 10 standards and quirks modes for improved interoperability and compliance with HTML5.

Source: https://msdn.microsoft.com/en-us/library/hh801214(v=vs.85).aspx