简体   繁体   English

IE条件注释在IE 11 Windows 8.1和开发工具中不起作用

[英]IE conditional comments not working in IE 11 Windows 8.1 and Development Tool

My computer is running Windows 8.1 Pro with IE : 11.0.9600 我的计算机运行的是带有IE的Windows 8.1 Pro:11.0.9600

<!--[if IE 8]> 
<script type="text/javascript" src="libs/ie/IE8.js">          </script>
<![endif]-->
<!--[if IE 9]> 
    <script type="text/javascript" src="libs/ie/IE9.js"></script>
<![endif]-->
<!--[if lt IE 9]>
    <script type="text/javascript" src="libs/html5shiv/html5shiv.js"></script>
    <script type="text/javascript" src="libs/respond/respond.min.js"></script>
<![endif]-->

When I browse in IE using the Development Tools and switch the mode to IE 8, nothing changes! 当我使用开发工具在IE中浏览并将模式切换为IE 8时,没有任何变化!

How do I fix it? 我如何解决它? Thanks in advance. 提前致谢。

IE has terrible backwards preservation. IE具有可怕的向后保存。

If you want to test in IE8 the only way to get reliable results is to run IE8. 如果要在IE8中进行测试,则获得可靠结果的唯一方法是运行IE8。

Sorry. 抱歉。

Because browser sniffing causes many problems IE removed conditional comment support like this. 由于浏览器嗅探会导致许多问题,因此IE删除了这样的条件注释支持。 Instead you should do feature detection. 相反,您应该进行特征检测。 For example 例如

if("localStorage" in window){}

Feature detection will always tell you if something is supported and you can adjust as needed from there. 功能检测将始终告诉您是否支持某些功能,您可以根据需要进行调整。 Browser Sniffing makes far too many assumptions, many of which of incorrect. 浏览器嗅探做出了太多的假设,其中许多是不正确的。 It is also not future-friendly, where feature detection is a feature friendly technique. 它也不是对未来友好的,因为特征检测是一种对特征友好的技术。

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

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