0

From this previous question I found that the code below can determine if a user has IE, and then run js-code specific to them. But when I used the code on my site, the effect was the opposite. On other browsers the code is fired, on IE not. What am I doing wrong?

<![if !IE]>

<script type="text/javascript">
$(document).ready(function() {
$(".box.2").fadeOut(1500);
});
</script>

<![endif]>
Community
  • 1
  • 1
DannyCruzeira
  • 564
  • 1
  • 6
  • 19

3 Answers3

6

Remove the ! in front of IE - it reverses the sense of the test and means don't do this on IE!

To ensure that other browsers ignore the text, write the comment thus:

<!--[if IE]>
...
<![endif]-->

NB: Microsoft have dropped support for conditional comments when using IE 10 in full HTML5 mode.

Alnitak
  • 334,560
  • 70
  • 407
  • 495
0

Change <![if !IE]> to <![if IE]>

Anoop
  • 23,044
  • 10
  • 62
  • 76
0

It's quite logical: when you check <![if !IE]>, your branching on !IE, not Internet Explorer, just drop the !: <![if IE]> and you're good to go. Like I'm ok to post this answer, having typed a sufficient amount of chars

Elias Van Ootegem
  • 74,482
  • 9
  • 111
  • 149