在網(wǎng)站開發(fā)中不免因?yàn)楦鞣N兼容問題 兼容問題苦惱,針對(duì)兼容問題 兼容問題,其實(shí) IE 給出了解決方案。 Google也給出了解決方案。 百度也應(yīng)用了這種方案去解決 IE 的兼容問題。
百度源代碼如下<metahttp-equiv=X-UA-Compatiblecontent=IE=EmulateIE7>
1,<meta http-equiv=X-UA-Compatible content=IE=EmulateIE7>或者<metahttp-equiv=“X-UA-Compatible”content=“IE=7″>,,這句話的意思是強(qiáng)制使用 IE7模式來解析網(wǎng)頁(yè)代碼!
2,<metahttp-equiv=“X-UA-Compatible”content=“IE=8″>,這句話的意思是強(qiáng)制使用 IE8模式來解析網(wǎng)頁(yè)代碼?。ㄓ玫帽容^少)
3,<metahttp-equiv=“X-UA-Compatible”content=“IE=6″><!- IE6 mode ->
<metahttp-equiv=“X-UA-Compatible”content=“IE=5″><!- IE5 mode ->
強(qiáng)制 IE8使用 IE6或 IE5模式來解析
4,如果一個(gè)特定版本的 IE 支持所要求的兼容性模式多于一種,就這么寫,如: <metahttp-equiv=“X-UA-Compatible”content=“IE=5; IE=8″/>
如果服務(wù)器是自己的話,可以在服務(wù)器上定義一個(gè)自訂標(biāo)頭來為它們的網(wǎng)站預(yù)設(shè)一個(gè)特定的文件兼容性模式。這個(gè)特定的方法取決于你的網(wǎng)站服務(wù)器。 錄入下列的 web.config 文件使 Microsoft Internet Information Services (IIS)能定義一個(gè)自訂標(biāo)頭以自動(dòng)使用 IE7 mode 來編譯所有網(wǎng)頁(yè)。
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<httpProtocol>
<customHeaders>
<add name="X-UA-Compatible" value="IE=EmulateIE7">
</customHeaders>
</httpProtocol>
</system.webServer>
</configuration>
另外還有一起其他的解決方案,例如 google 的 ie7 – js 中是一個(gè) JavaScript 庫(kù)(解決 IE 與 W3C 標(biāo)準(zhǔn)的沖突的 JS 庫(kù)),使微軟的 Internet Explorer 的行為像一個(gè) Web 標(biāo)準(zhǔn)兼容的瀏覽器,支持更多的 W3C 標(biāo)準(zhǔn),支持 CSS2、CSS3 選擇器。它修復(fù)了許多的 HTML 和 CSS 問題,并使得透明 PNG 在 IE5、IE6下正確顯示。
5,使 IE5,IE6兼容到 IE7模式(推薦)
<!–[if lt IE 7]>
<script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE7.js” type=”text/javascript”></script>
<![endif]–>
6,使 IE5,IE6,IE7兼容到 IE8模式 1
<!–[if lt IE 8]> 20 <script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE8.js” type=”text/javascript”></script>
<![endif]–>
7、使 IE5,IE6,IE7,IE8兼容到 IE9模式
<!–[if lt IE 9]> 23 <script src=”http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js”></script>
<![endif]–>
留言反饋