日韩av爽爽爽久久久久久,嫩草av久久伊人妇女超级a,久久精品a亚洲国产v高清不卡,久久成人国产精品一区二区

知識學(xué)堂
  • ·聯(lián)系電話:+86.023-75585550
  • ·聯(lián)系傳真:+86.023-75585550
  • ·24小時手機:13896886023
  • ·QQ 咨 詢:361652718 513960520
當(dāng)前位置 > 首頁 > 知識學(xué)堂 > 網(wǎng)站建設(shè)知識
HTML代碼技巧:HTML注釋表達式判斷IE版本
更新時間:2012-05-17 | 發(fā)布人:本站 | 點擊率:1123

如何讓靜態(tài)HTML代碼根據(jù)不同IE版本顯示不同內(nèi)容。 這里的技巧就是利用IE的HTML注釋表達式。

HTML 的注釋格式是 <!-- Comment content --> , IE 對HTML注釋做了一些擴展,使之可以支持條件判斷表達式:

<!--[if expression]> HTML <![endif]--> 當(dāng)表達式expression 為True 的時候,顯示 HTML 內(nèi)容。

例子:

view plaincopy to clipboardprint?
<!--[if IE 5]>
<p>Welcome to Internet Explorer 5.</p>
<![endif]-->
<!--[if IE 5]>
<p>Welcome to Internet Explorer 5.</p>
<![endif]-->

和編程語言類似,這里的表達式還支持大于(gt)、小于(lt)、 與或非 等操作符。 下面是一些例子。

[if IE] 判斷是否IE

[if IE 7] 判斷是否是IE7

[if !IE] 判斷是否不是IE

[if lt IE 5.5] 判斷是否是IE5.5 以下版本。 (<)

[if lte IE 6] 判斷是否等于IE6 版本或者以下 (<=)

[if gt IE 5] 判斷是否IE5以上版本 (> )

[if gte IE 7] 判斷是否 IE7 版本或者以上

[if !(IE 7)] 判斷是否不是IE7

[if (gt IE 5)&(lt IE 7)] 判斷是否大于IE5, 小于IE7

[if (IE 6)|(IE 7)] 判斷是否IE6 或者 IE7

代碼示例:

view plaincopy to clipboardprint?


<!--[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 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]-->

 

注:IE5 以下的版本不支持這種注釋擴展。 不過現(xiàn)在也很難找到IE4了 ... :)