-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 is supporting Monica
  • 142,542
  • 55
  • 282
  • 355
zozo
  • 7,781
  • 18
  • 72
  • 128

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
  • 47,464
  • 10
  • 95
  • 116
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
  • 13,721
  • 33
  • 104
  • 184