if 条件语句不适用于 IE 11

我使用的是 IE 11 版本.是否有其他解决方案可以执行以下操作:

I am using IE 11 version. Is there any other solution to do the following:

当我尝试在 html webapge 中使用条件 IE 子句时没有任何反应.谁能帮我调试一下这个问题.

Nothing happens when I try to use conditional IE clause in the html webapge. Can anyone help me debug this issue please.

<!--[if IE]>
<a href="next-page.php" class="start-button">CLICK ME</a>
<![endif]-->

推荐答案

条件语句在 IE 10 或 11 中不起作用

已在 Internet Explorer 10 标准和怪癖模式中删除了对条件注释的支持,以提高互操作性和与 HTML5 的合规性.这意味着条件注释现在被视为常规注释,就像在其他浏览器中一样.此更改可能会影响专门为 Windows Internet Explorer 编写的页面或使用浏览器嗅探来改变其在 Internet Explorer 中的行为的页面.

Support for conditional comments has been removed in Internet Explorer 10 standards and quirks modes for improved interoperability and compliance with HTML5. This means that Conditional Comments are now treated as regular comments, just like in other browsers. This change can impact pages written exclusively for Windows Internet Explorer or pages that use browser sniffing to alter their behavior in Internet Explorer.

如果您真的只需要在那些浏览器上执行代码,而您可能不应该这样做,您可以使用 JavaScript 来做一些 特征检测作为替代方案.

If you really need to execute code just on those browsers, and you probably shouldn't, you can use JavaScript to do some feature detection as an alterantive.

相关文章