在 HTML/CSS 中检测没有 JavaScript 的 IE11
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21204017/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
detect IE11 without JavaScript in HTML/CSS
提问by user984003
I have been using the following trick to make browser-specific HTML:
我一直在使用以下技巧来制作特定于浏览器的 HTML:
<!--[if (IE)]> <div class= "ie"> <![endif]-->
<!--[if !(IE)]><!--> <div class= "not_ie"> <!--<![endif]-->
</div>
This does not work with IE11. Any new tricks to use?
这不适用于 IE11。有什么新的使用技巧吗?
I can detect it using JavaScript:
我可以使用 JavaScript 检测它:
Detecting IE11 using CSS Capability/Feature Detection
使用 CSS Capability/Feature Detection 检测 IE11
or
或者
Object.hasOwnProperty.call(window, "ActiveXObject") && !window.ActiveXObject)
but I'm hoping to avoid that.
但我希望避免这种情况。
回答by Kovah
IE 11 does not longer support conditional comments in your HTML code. So you have to use Javascript.
IE 11 不再支持 HTML 代码中的条件注释。所以你必须使用Javascript。