简体   繁体   English

条件注释在ie11中不起作用

[英]Conditional comments not working in ie11

I'm trying to use conditional comments to load webcomponents polymer polyfill on ie11 and webcomponente-lite polyfill on ohter browser so I have: 我试图使用条件注释在其他浏览器上在ie11上加载webcomponents聚合物polyfill和在其他浏览器上加载webcomponente-lite polyfill,所以我有:

<head>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bower_components/roboto-condensed/css/roboto-condensed.css">
<!--[if IE]>
<script src="bower_components/webcomponentsjs/webcomponents.min.js"></script>
<![endif]-->
<!--[if !IE]><!-->
<script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script>
<!--<![endif]-->

The issue is that webcomponents-lite.min.js is always loaded, event in IE11 问题是,始终会加载webcomponents-lite.min.js,这是IE11中的事件

Any suggestion? 有什么建议吗?

IE 11 does not support conditional comments. IE 11不支持条件注释。

Conditional comments are no longer supported 不再支持条件注释

Impact Applies to Internet Explorer 10 and later. 影响适用于Internet Explorer 10及更高版本。 Affects IE10 Standards mode and later, including interoperable quirks mode. 影响IE10标准模式和更高版本,包括可互操作的怪癖模式。 Support for conditional comments has been removed in Internet Explorer 10 standards and quirks modes for improved interoperability and compliance with HTML5. Internet Explorer 10标准和怪异模式中已删除了对条件注释的支持,以提高互操作性和与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. 此更改可能会影响专门为Windows Internet Explorer编写的页面或使用浏览器嗅探来更改其在Internet Explorer中行为的页面。

You'll need to try another way to target IE11 specifically. 您需要尝试另一种专门针对IE11的方法。

Searching around SO brought me to this answer, which uses feature detection to determine whether or not to load Polymer's polyfills. 搜索SO使我得到了这个答案,该答案使用特征检测来确定是否加载Polymer的polyfills。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM