0

I am extreamly new to HTML,

my goal is to set a global js variable to true when my website is running on IE.

I started by writing

<script> var runningIE = false;</script>
<!--[if IE ]>
    Special instructions for IE here
    <script> runningIE = true;</script>
<![endif]-->

no matter where I put this code (header, body) I don't see Special instructions for IE here printed anywhere not runningIE would be set to true on IE.

What am I missing here?

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
Kam
  • 5,878
  • 10
  • 53
  • 97

1 Answers1

0

You are probably testing in IE 10, which does not support conditional comments (browser sniffing is not a good idea in the first place, and IE has improved a lot since the days when it was useful to throw a huge pile of IE specific fixes into a condcom).

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • 1
    Use feature detection instead of browser detection. – Quentin Jul 13 '13 at 06:35
  • There are still [a lot of cases](https://github.com/Modernizr/Modernizr/wiki/Undetectables) where UA sniffing is useful. Alternatively, use [conditional compilation](http://msdn.microsoft.com/en-us/library/ie/121hztk3%28v=vs.94%29.aspx). – user123444555621 Jul 13 '13 at 06:40