I have a page that has the conditional comment:
<%@ Page language="c#" %>
<html>
<head>
<title>ASP.NET Application</title>
<!--[if lt IE 8]><script type="text/javascript" src="scripts/json_parse.js"></script><![endif]-->
</head>
<body>
test
</body>
<html>
When I do it like above, it throws a compilation error saying it expects a closing “script” tag. But the below code (which should end up with the same page) works perfectly:
<%@ Page language="c#" %>
<html>
<head>
<title>ASP.NET Application</title>
<!--[if lt IE 8]>
<% Response.Write( "<script type=\"text/javascript\" src=\"scripts/json_parse.js\"></script>" ); %>
<![endif]-->
</head>
<body>
test
</body>
<html>
Why does it have a problem with IE conditionals? The script tag is inside a comment and is not “runat”.
This is a case where you want the conditional comments to be revealed to downlevel browsers, not hidden by uplevel browsers, so there is a slightly different syntax to use:
See this MSDN article for detailed information.