一.指定文件兼容性模式
要為你的網頁指定文件模式,需要在你的網頁中使用meta元素放入X-UA-Compatible http-equiv 標頭。
1. 強制IE8使用IE8模式來解析,而且那個兼容性視圖 按鈕也被去掉了
<meta http-equiv="X-UA-Compatible" content="IE=8">
2. Google Chrome Frame也可以讓IE用上Chrome的引擎:
<meta http-equiv="X-UA-Compatible" content="chrome=1" />
3.強制IE8使用IE7模式來解析
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"><!-- IE7 mode --> 或者
<meta http-equiv="X-UA-Compatible" content="IE=7"><!-- IE7 mode -->
4.強制IE8使用IE6或IE5模式來解析
<meta http-equiv="X-UA-Compatible" content="IE=6"><!-- IE6 mode -->
<meta http-equiv="X-UA-Compatible" content="IE=5"><!-- IE5 mode -->
5.如果一個特定版本的IE支持所要求的兼容性模式多於一種,如:
<meta http-equiv="X-UA-Compatible" content="IE=5; IE=8" />
二.設定網站服務器以指定預設兼容性模式
網站管理員可籍着為網站定義一個自訂標頭來為他們的網站預設一個特定的文件兼容性模式。這個特定的方法取決於你的網站服務器。舉例來說,下列的 web.config文件使Microsoft Internet Information Services (IIS)能定義一個自訂標頭以自動使用IE7 mode來編譯所有網頁。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<clear />
<add name="X-UA-Compatible" value="IE=EmulateIE7" />
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
若你已於網站服務器指定了一個預設的文件兼容性模式,你可以在個別頁面上指定不同的文件兼容性模式來蓋過它。在網頁中指定的模式優先權高於服務器中所指定的模式。