<html>
<head>
<!-- [If IE]><script>alert('IE!')</script><![endif] -->
</head>
<body>
<p>
Hello World
</p>
</body>
</html>
Is there something wrong with this, or do I need to add a DOCtype / meta heading to get it to work?
This is just to clarify (since noone has really).
It's the space between <!-- and [If IE] aswell as the space after [endif] that breaks your code. It's not there in any of the answers that are previous to mine, therefor they work and yours do not.
Bad:
<!-- [If IE]> <![endif] -->
Good:
<!--[If IE]> <![endif]-->
<!DOCTYPE html> is a good practice, but not needed for this to work.
This should work fine:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Untitled Document</title>
<!--[if IE]><script src="global.js"></script><![endif]-->
</head>
<body>
<p>Hello world</p>
</body>
</html>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With