Search code examples
javascriptinternet-explorerconditional-comments

Conditional IE statement - run script


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?


Solution

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

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