代码如下:
<
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >IE条件注释 </title>
</head>
< body >
< ! --仅IE6-- >
< ! --[if IE 6]><h3>仅IE6</h3><![endif]-- >
< ! --除IE外浏览器-- >
< ! --[if !IE 6]><!-- > < h3 >除IE6外都可识别 </h3> < ! --<![endif]-- >
</body>
</html>
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" />
< title >IE条件注释 </title>
</head>
< body >
< ! --仅IE6-- >
< ! --[if IE 6]><h3>仅IE6</h3><![endif]-- >
< ! --除IE外浏览器-- >
< ! --[if !IE 6]><!-- > < h3 >除IE6外都可识别 </h3> < ! --<![endif]-- >
</body>
</html>
先看下结果:
ie6:
仅IE6
FF3(火狐3)\Opera 9.51:
除IE6外都可识别
这个可以用作一些对ie6的hack技术。
注:
<!--[if IE 6]>
在这里可以书写针对IE6的代码
<![endif]-->
在这里可以书写针对IE6的代码
<![endif]-->
而
<
!
--[if !IE 6]>
<!--
>
<
h3
>除IE6外都可识别
</h3>
<
!
--
<![endif]--
>
其实就是普通的注释,但是里面有ie可以识别的条件注释。
本文转自 xcf007 51CTO博客,原文链接:
http://blog.51cto.com/xcf007/102821
,如需转载请自行联系原作者