1. 程式人生 > ><meta http-equiv="X-UA-Compatible" content="ie=edge">的作用

<meta http-equiv="X-UA-Compatible" content="ie=edge">的作用

本人對該知識點了解不深,本文采用Victor,再進一步!的文章,如果有人看到本頁,請直接進入https://www.cnblogs.com/victor5230/p/5846832.html,瀏覽原文。

 

對於IE8及以上版本,例如:

   1: <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7" />

 

強制瀏覽器按照特定的版本標準進行渲染。但不支援IE7及以下版本。如果用分號(;)分隔,對於不同的瀏覽器版本就有不同的相容性,例如

   1: <meta http-equiv="X-UA-Compatible" content="IE=7; IE=9" />

 

以上就表明,將IE8和IE7按照IE7標準渲染,但是IE9還是按照IE9的標準渲染。它允許有不同的向後相容水平。儘管在真實情況中,你只要選擇一種版本:

   1: <meta http-equiv="X-UA-Compatible" content="IE=8" />

 

  這對於測試和維護會更加簡單。而通常更加有用的方式就是進行模擬模擬
   1: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

 

對於IE=EDGE

   1: <meta http-equiv="X-UA-Compatible" content="IE=Edge" />

 

這意味著,會強制瀏覽器按照最新的標準去渲染。就像在Google’s CDN使用最新版本的JQuery一樣,這是按照最新版本,但也可能由於沒有固定的版本而破壞你的佈局。

最後,考慮下面這個

   1: <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />

 

新增”chrome=1“將允許站點在使用了谷歌瀏覽器內嵌框架(Chrome Frame)的客戶端渲染,對於沒有使用的,則沒有任何影響。

For more information, there is plenty to read here, and if you want to learn about ChromeFrame (which I recommend) you can learn about its implementation here.

 

PS:X-UA-Compatible是針對 IE8 版本的一個特殊檔案頭標記,用於為 IE8 指定不同的頁面渲染模式,對於ie8之外的瀏覽器是不識別的。

目前絕大多數網站都用<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ >來作為IE8的相容方法。為了避免製作出的頁面在IE8下面出現錯誤,建議直接將IE8使用IE7進行渲染。也就是直接在頁面的header的meta標籤中加入如下程式碼:

<meta http-equiv=”X-UA-Compatible” content=”IE=7″ />

<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ >

<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE8″ >

但是<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ >仍然是首選。

StackOverFlow原連結;http://stackoverflow.com/questions/14611264/x-ua-compatible-content-ie-9-ie-8-ie-7-ie-edge?answertab=active#tab-top

 

對於IE8及以上版本,例如:

   1: <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7" />

 

強制瀏覽器按照特定的版本標準進行渲染。但不支援IE7及以下版本。如果用分號(;)分隔,對於不同的瀏覽器版本就有不同的相容性,例如

   1: <meta http-equiv="X-UA-Compatible" content="IE=7; IE=9" />

 

以上就表明,將IE8和IE7按照IE7標準渲染,但是IE9還是按照IE9的標準渲染。它允許有不同的向後相容水平。儘管在真實情況中,你只要選擇一種版本:

   1: <meta http-equiv="X-UA-Compatible" content="IE=8" />

 

  這對於測試和維護會更加簡單。而通常更加有用的方式就是進行模擬模擬
   1: <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" />

 

對於IE=EDGE

   1: <meta http-equiv="X-UA-Compatible" content="IE=Edge" />

 

這意味著,會強制瀏覽器按照最新的標準去渲染。就像在Google’s CDN使用最新版本的JQuery一樣,這是按照最新版本,但也可能由於沒有固定的版本而破壞你的佈局。

最後,考慮下面這個

   1: <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />

 

新增”chrome=1“將允許站點在使用了谷歌瀏覽器內嵌框架(Chrome Frame)的客戶端渲染,對於沒有使用的,則沒有任何影響。

For more information, there is plenty to read here, and if you want to learn about ChromeFrame (which I recommend) you can learn about its implementation here.

 

PS:X-UA-Compatible是針對 IE8 版本的一個特殊檔案頭標記,用於為 IE8 指定不同的頁面渲染模式,對於ie8之外的瀏覽器是不識別的。

目前絕大多數網站都用<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ >來作為IE8的相容方法。為了避免製作出的頁面在IE8下面出現錯誤,建議直接將IE8使用IE7進行渲染。也就是直接在頁面的header的meta標籤中加入如下程式碼:

<meta http-equiv=”X-UA-Compatible” content=”IE=7″ />

<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ >

<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE8″ >

但是<meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE7″ >仍然是首選。

StackOverFlow原連結;http://stackoverflow.com/questions/14611264/x-ua-compatible-content-ie-9-ie-8-ie-7-ie-edge?answertab=active#tab-top