[英]How to comment out IE conditional comments?
I'm just wondering if it's possible to comment out IE conditional comments themselves (for testing purposes)? 我只是想知道是否可以自己评论IE条件评论(用于测试目的)? The following does not work:
以下不起作用:
<!-- <!--[if IE 7]> some code <![endif]--> -->
Thanks in advance! 提前致谢! flexx
FLEXX
No, it isn't possible. 不,这是不可能的。
SGML/HTML/XML/XHTML comments cannot be nested. SGML / HTML / XML / XHTML注释不能嵌套。
我想你可以插入一些东西使它们无效:
<!--\[if IE 7]> some code <!\[endif]-->
<!--[if IE 70]> some code <![endif]-->
:)
If I were you I'd use a template systems like Template Toolkit and then Just include or exclude the comment conditionally, based on some variable you could set at runtime. 如果我是你,我会使用像Template Toolkit这样的模板系统,然后根据你在运行时设置的一些变量,有条件地包含或排除注释。
Template Toolkit http://template-toolkit.org/ 模板工具包http://template-toolkit.org/
如果您通过.asp或aspx等服务器发送它,那么您当然可以在服务器端发表评论。
You can't nest comments, but you can comment them out by adding an extra <!--
to the beginning. 你不能嵌套评论,但你可以通过在开头添加额外的
<!--
来评论它们。 Your example from above changes from <!-- <!--[if IE 7]> some code <![endif]--> -->
to <!-- <!--[if IE 7]> some code <![endif]-->
. 你上面的例子从
<!-- <!--[if IE 7]> some code <![endif]--> -->
变为<!-- <!--[if IE 7]> some code <![endif]-->
。 Just take out the extra -->
and it should comment out that pesky conditional. 只需取出额外的
-->
它应该注释掉那个讨厌的条件。
Tested successful in Firefox 3.5.2 and IE 7.0.5730.13CO 在Firefox 3.5.2和IE 7.0.5730.13CO中测试成功
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.