如何在某些情况下仅针对Internet Explorer10,如特定于Internet Explorer的CSS或特定于Internet Explorer的JavaScript代码?
我试过了,但不起作用:
<!--[if IE 10]> <html class="no-js ie10" lang="en"> <![endif]-->
<!--[if !IE]><!--> <html lang="en" class="no-js"> <!--<![endif]-->10 10忽略条件注释,使用<html lang="en" class="no-js">而不是<html class="no-js ie10" lang="en">。
发布于 2012-12-19 22:39:28
也许你可以像这样尝试一些jQuery:
if ($.browser.msie && $.browser.version === 10) {
$("html").addClass("ie10");
}要使用此方法,您必须包含jQuery迁移库,因为此函数已从主jQuery库中删除。
对我来说挺好的。但肯定不能替代条件注释!
发布于 2013-06-14 09:57:38
IE Standards Support Documentation是一个很好的起点。
以下是如何在JavaScript中定位IE10的方法:
if ("onpropertychange" in document && !!window.matchMedia) {
...
}下面是如何在CSS中定位IE10的方法:
@media all and (-ms-high-contrast: none) {
...
}如果需要通过CSS过滤或重置IE11,请参阅另一个问题:How to write a CSS hack for IE 11?
发布于 2012-12-30 08:48:00
这里发布的两个解决方案(稍微做了一些修改)都可以工作:
<!--[if !IE]><!--><script>if(/*@cc_on!@*/false){document.documentElement.className='ie10';}</script><!--<![endif]-->或
<script>if(Function('/*@cc_on return 10===document.documentMode@*/')()){document.documentElement.className='ie10';}</script>在css链接之前,您可以在html页面的head标记中包含上述任意一行。然后在css文件中指定您的样式,将"ie10“类作为父类:
.ie10 .myclass1 { }瞧!--其他浏览器保持不变。而且你不需要jQuery。您可以在这里看到我如何实现它的示例:http://kardash.net。
https://stackoverflow.com/questions/9900311
复制相似问题