中文字幕免费精品_亚洲视频自拍_亚洲综合国产激情另类一区_色综合咪咪久久

IE條件語句IE hack大全
來源:易賢網 閱讀:1221 次 日期:2014-08-11 16:31:32
溫馨提示:易賢網小編為您整理了“IE條件語句IE hack大全”,方便廣大網友查閱!

Conditional comments work as follows:

代碼如下:

<!--[if IE 6]>Special instructions for IE 6 here<![endif]-->

[code]

Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely.

IE, though, has been programmed to recognize the special <!--[if IE]> syntax, resolves the ifand parses the content of the conditional comment as if it were normal page content.

Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files. I'd have preferred to put the special styles in the CSS file, but that's impossible. You can also put an entire new <link> tag in the conditional comment referring to an extra style sheet.

Example

Below I added a lot of conditional comments that print out messages according to your IE version.

Note however, that if you use multiple Explorers on one computer, the conditional comments will render as if all these Explorer versions are the highest Explorer version available on your machine (usually Explorer 6.0).

Test

Below are a few conditional comments that reveal the IE version you're using.

According to the conditional comment this is IE

According to the conditional comment this is IE 7

According to the conditional comment this is IE lower than 9

According to the conditional comment this is IE lower or equal to 7

According to the conditional comment this is IE greater than 6

Code

The syntax I use is:

[code]

<p class="accent">

<!--[if IE]>

According to the conditional comment this is IE<br />

<![endif]-->

<!--[if IE 6]>

According to the conditional comment this is IE 6<br />

<![endif]-->

<!--[if IE 7]>

According to the conditional comment this is IE 7<br />

<![endif]-->

<!--[if IE 8]>

According to the conditional comment this is IE 8<br />

<![endif]-->

<!--[if IE 9]>

According to the conditional comment this is IE 9<br />

<![endif]-->

<!--[if gte IE 8]>

According to the conditional comment this is IE 8 or higher<br />

<![endif]-->

<!--[if lt IE 9]>

According to the conditional comment this is IE lower than 9<br />

<![endif]-->

<!--[if lte IE 7]>

According to the conditional comment this is IE lower or equal to 7<br />

<![endif]-->

<!--[if gt IE 6]>

According to the conditional comment this is IE greater than 6<br />

<![endif]-->

<!--[if !IE]> -->

According to the conditional comment this is not IE<br />

<!-- <![endif]-->

</p>

Note the special syntax:

gt: greater than

lte: less than or equal to

Also note the last one. It has a different syntax, and its contents are shown in all browsers that are not IE:

代碼如下:

<!--[if !IE]> -->

CSS hack?

Are conditional comments CSS hacks? Strictly speaking, yes, since they can serve to give special style instructions to some browsers. However, they do not rely on one browser bug to solve another one, as all true CSS hacks do. Besides, they can be used for more than CSS hacks only (though that rarely happens).

Since conditional comments are not based on a browser hack but on a deliberate feature I believe they are safe to use. Sure, other browsers could implement conditional comments, too (though as yet none have done so), but they're unlikely to react to the specific query <!--[if IE]>.

I use conditional comments, though sparingly. First I see if I can find a real CSS solution to an Explorer Windows problem. If I can't, though, I don't hesitate to use them.

Comment tag

A reader told me IE also supports the (non-standard) <comment> tag.

<p>This is <comment>not</comment> IE.</p>

This isIE.

This tag might be a replacement for the !IE conditional comment.

更多信息請查看IT技術專欄

更多信息請查看網絡編程
易賢網手機網站地址:IE條件語句IE hack大全
由于各方面情況的不斷調整與變化,易賢網提供的所有考試信息和咨詢回復僅供參考,敬請考生以權威部門公布的正式信息和咨詢為準!

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼
關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
云南網警備案專用圖標
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網
云南網警報警專用圖標
主站蜘蛛池模板: 通道| 渝北区| 广丰县| 天长市| 美姑县| 雅安市| 饶阳县| 伊吾县| 准格尔旗| 巨鹿县| 金湖县| 静乐县| 墨脱县| 文昌市| 平邑县| 翁牛特旗| 临武县| 樟树市| 周宁县| 江油市| 亳州市| 衡南县| 吕梁市| 巴林左旗| 安远县| 乐至县| 玛曲县| 昆明市| 阳谷县| 鞍山市| 葵青区| 嘉峪关市| 东兴市| 葫芦岛市| 兴安县| 黑山县| 海盐县| 湛江市| 朔州市| 赤水市| 南安市|