-2

I have a lame problem:

If I use something like:

<!--[if IE]>
     Random text
<![endif]-->

and I open page in IE (9) I naturally see the text "Random text". Everything is ok.

If I use:

<!--[if IE]>
<script type="text/javascript">
    alert("aaa);
</script>
<![endif]-->

Nothing happens.

I need to run a specific script for IE... can any1 help me with it?

gdoron
  • 147,333
  • 58
  • 291
  • 367
zozo
  • 8,230
  • 19
  • 79
  • 134
  • 3
    Is that a syntax error I see: ` alert("aaa);` (missing close quote) – slebetman Nov 05 '12 at 08:18
  • 2
    @zozo: This is question is unlikely to help anyone in the future (it's a simple typo), you might flag it and ask the moderators to remove it. – T.J. Crowder Nov 05 '12 at 08:23
  • 1
    By the way @zozo, you should have got an error in the console for this script, did you look for errors? – gdoron Nov 05 '12 at 08:26

2 Answers2

4

You have a syntax error in your Javascript. Try this:

<!--[if IE]>
<script type="text/javascript">
    alert("aaa");
</script>
<![endif]-->
Sebastian Paaske Tørholm
  • 49,493
  • 11
  • 100
  • 118
  • Yeah, that was a miss-type :). Srry for lame question. Put some minuses into it so I learn to check my spelling before asking something ;). – zozo Nov 05 '12 at 08:20
  • 2
    @zozo. But why did you edit the question, now the answer doesn't make sense! – gdoron Nov 05 '12 at 08:22
  • 1
    @zozo: Definitely don't fix it in the question. – T.J. Crowder Nov 05 '12 at 08:23
  • I edited because I thought my " didn't work here but i had the same problem in the script. Need to change the keyboard. – zozo Nov 05 '12 at 08:24
0

Use the script to check if it's IE.
EDIT: actually check out some of the answers here, they're exactly what you want.
For example one person posted this solution which uses a very different approach

<script>runFancy = true;</script>
<!--[if IE]>
<script type="text/javascript">
    runFancy = false;
 </script> // <div>The HTML version for IE went here</div>
<![endif]-->
Community
  • 1
  • 1
Celeritas
  • 14,489
  • 36
  • 113
  • 194