如何编写一个IE条件注释来同时定位所有IE版本? [英] How to write one IE conditional comment to target all IE versions at once?
本文介绍了如何编写一个IE条件注释来同时定位所有IE版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想只为所有IE版本6,7和8使用JavaScript。
I want to use a JavaScript only for all IE version 6,7 and 8.
推荐答案
嵌套条件(错误):
<!--[if lte IE 8]>
<!--[if gte IE 6]>
<!-- your stuff here -->
<![endif]-->
<![endif]-->
编辑:
正如Martha强调的那样,嵌套条件不要'工作,使用&
:
<!--[if (lte IE 8) & (gte IE 6)]>
<!-- your stuff here -->
<![endif]-->
来自 MSDN :
<!--[if IE]><p>You are using Internet Explorer.</p><![endif]-->
<![if !IE]><p>You are not using Internet Explorer.</p><![endif]>
<!--[if IE 7]><p>Welcome to Internet Explorer 7!</p><![endif]-->
<!--[if !(IE 7)]><p>You are not using version 7.</p><![endif]-->
<!--[if gte IE 7]><p>You are using IE 7 or greater.</p><![endif]-->
<!--[if (IE 5)]><p>You are using IE 5 (any version).</p><![endif]-->
<!--[if (gte IE 5.5)&(lt IE 7)]><p>You are using IE 5.5 or IE 6.</p><![endif]-->
<!--[if lt IE 5.5]><p>Please upgrade your version of Internet Explorer.</p><![endif]-->
<!--[if true]>You are using an <em>uplevel</em> browser.<![endif]-->
<![if false]>You are using a <em>downlevel</em> browser.<![endif]>
<!--[if true]><![if IE 7]><p>This nested comment is displayed in IE 7.</p><![endif]><![endif]-->
这篇关于如何编写一个IE条件注释来同时定位所有IE版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文