Frage

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?

War es hilfreich?

Lösung

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

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

Andere Tipps

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]-->
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top