If IE comments showing up in IE9

天大地大妈咪最大 提交于 2019-12-25 12:42:51

问题


This is what is happening when you visit my site in IE9 -

This is the code that is causing this:

<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<link rel="stylesheet" href="stylesheets/ie.css" media="screen" />
<![endif]-->
<!--[if !IE]-->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!--[endif]-->

<!--[if !IE]-->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!--[endif]-->

Thoughts?


回答1:


EDIT: fixed according to the commenters, thanks. See also the other answers.


Corrected code (second part):

<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->

<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->



回答2:


Actually, the "dashes" are correct, but first you must close the conditionals, like so:

<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->

<!--[if !IE]> -->
<link rel="stylesheet" href="stylesheets/sizeable.css" media="screen" />
<!-- <![endif]-->

Not adding the "dashes" will cause no browser to pay attention to these conditionals. Non-IE browsers do not read comments, so the code must be outside the comment for the !IE condition.




回答3:


<!--<![if (IE X)|(IE Y)]--><link href="../css/style.css" rel="stylesheet" type="text/css" media="all" /><!--<![endif]-->

Above conditional comment will work properly For Hiding Comment line you must have to add <!--<! in this format




回答4:


You're closing your comments prematurely. Your conditional comments should open like:

<!--[cond]>

and end like:

<![end]-->

You did the first one right, but because your opening tags end with -->, that closes the comment right there, so the link tag, which is supposed to be part of the comment, isn't, and is interpreted as regular HTML.

Hope that helps!



来源:https://stackoverflow.com/questions/9675750/if-ie-comments-showing-up-in-ie9

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!