现在的位置: 首页 > 综合 > 正文

关于IE和非IE浏览器的条件注释

2013年05月03日 ⁄ 综合 ⁄ 共 1266字 ⁄ 字号 评论关闭
下面一段代码是测试在微软的IE浏览器下的条件注释语句的效果

程序代码 程序代码
<!--[if IE]>
<h1>您正在使用IE浏览器</h1>
<![endif]-->
<!--[if IE 5]>
<h1>版本 5</h1>
<![endif]-->
<!--[if IE 5.0]>
<h1>版本 5.0</h1>
<![endif]-->
<!--[if IE 5.5]>
<h1>版本 5.5</h1>
<![endif]-->
<!--[if IE 6]>
<h1>版本 6</h1>
<![endif]-->
<!--[if IE 7]>
<h1>版本 7</h1>
<![endif]-->

下面的代码是在非IE浏览器下运行的条件注释

程序代码 程序代码
<!--[if !IE]><!-->
<h1>您使用不是 Internet Explorer</h1>
<!--<![endif]-->
最终在非IE和特殊的IE浏览器下起作用
(或者使用 lte lt 或者 gt gte来判断,如:
<!--[if lte IE 6]>
 在IE 6下显示的信息
<![endif]--> 
).

<!--[if IE 6]><!-->
<h1>您正在使用Internet Explorer version 6<br />
或者 一个非IE 浏览器</h1>
<!--<![endif]-->

-------------------------------------------------
<HTML>
<HEAD>
<TITLE>if IE-www.51windows.Net</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<META NAME="Author" CONTENT="51windows,海娃,haiwa">
<META NAME="Description" CONTENT="Power by 51windows.Net">
</HEAD>

<BODY>
<!--[if gte IE 5]>
<li>IE 5.0 - 6.x
<![endif]-->
<!--[if IE 5]>
<li>IE 5.0
<![endif]-->
<!--[if IE 5.5000]>
<li>IE 5.5
<![endif]-->
<!--[if IE 6]>
<li>IE 6.0
<![endif]-->
<!--[if gte IE 5.5000]>
<li>IE 5.5 - 6.x
<![endif]-->
<!--[if lt IE 6]>
<li>IE 5.0 - 5.5
<![endif]-->
</BODY>
</HTML>

<div style="position: absolute; top: 10; right: 10; width: 148; height: 18;cursor:hand">
<input type="button" name="Button" value="查看源代码" onClick= 'window.location = "view-source:" + window.location.href'></div>

抱歉!评论已关闭.