IE8 的 相容Quirks模式 Meta Tag(X-UA-Compatible)
IE8 的 相容Quirks模式 Meta Tag(X-UA-Compatible)
Microsoft 推出了 Internet Explorer 8 Beta 1, 裡面有一個非常大的改變: 微軟:IE8 預設模式將支援網路標準
, 節錄裡面幾點:
- 微軟宣布,IE8一推出時,就會以標準相容模式(standards compatibility mode)作為預設的成像引擎(rendering engine)。微軟先前已表示,新版瀏覽器可以通過Acid2 rendering測試。
- 就IE8而言,微軟計劃提供三種rendering模式:新的標準相容(standards-compliant)模式、IE7成像引擎、以及一個展示舊型網站的選項。因為新版瀏覽器改變了預設環境,若網站希望IE8沿用IE7的引擎,就必須在各自的網站編碼中加入一個標籤(tag)。
所以 IE8 的預設模式會如下(取自: IEBlog: The Default Layout Mode):
- Known standards DOCTYPEs and unknown DOCTYPEs: IE8 Standards
- Quirks mode DOCTYPEs (includes the absence of a DOCTYPE): Quirks
- 關於 DOCTYPE 詳可見: MSDN 對 !DOCTYPE 的介紹 和 HTML 標準驗證
Acid2
依這篇文章 Internet Explorer 8 and Acid2: A Milestone 寫說 IE8 已經能正確將 Acid2 Face畫出來, 關於 Acid2 可見下面連結:
- Acid2: The Guided Tour
- The Second Acid Test - Acid2 測試頁
X-UA-Compatible 參數
基本上 IE8 預設模式直接支援標準是很好, 但是另外一個問題是, 有數不清的 RD 要熬夜了... XD
幸好 M$ 也有提供快速解法(就是說, 來不及改的, 就先把下面 META Tag 塞進去, 畫面應該就不會大爆炸), 取自 Windows Internet Explorer 8 Beta 1 for Developers: Technology Overview(Developer whitepaper)
, 下載此 Developer whitepaper 的 doc 檔, 裡面有說明 META 的 X-UA-Compatible 可以設定讓 IE8 採用舊的模式, 模式/參數目前有以下幾種:
- IE=5: "Quirks" mode
- IE=7: "Standards" mode
- IE=8: Internet Explorer 8 Standards mode
- IE=edge: Uses latest standards that Internet Explorer 8 and any future versions of the browser support. Not recommended for production sites.
範例 (記得 META Tag 要擺在 <header></header> 中)
- <meta http-equiv="X-UA-Compatible" content="IE=8" >
- <meta http-equiv="X-UA-Compatible" content="IE=7" >
- 我猜有不少網頁都要用此 <meta http-equiv="X-UA-Compatible" content="IE=5" > 模式, 如果是用這種 Quirks 模式的, 盡量找個時間<strike>重寫</strike>重新設計規劃吧~~ XD