在網站前端寫代碼的過程中,很多時間IE各個版本的兼容問題很難整,F在百度與谷歌都有了一行解決這種兼容性的代碼了。如下面的。
辦法一
百度也應用了這種方案去解決IE的兼容問題
百度源代碼如下
1 <!Doctype html>
2 <htmlxmlns=http://www.w3.org/1999/xhtmlxmlns:bd=http://www.baidu.com/2010/xbdml>
3 <head>
4 <metahttp-equiv=Content-Typecontent=“text/html;charset=utf-8″>
5 <metahttp-equiv=X-UA-Compatiblecontent=IE=EmulateIE7>
6 <title>百度一下,你就知道</title>
7 <script>varwpo={start:newDate*1,pid:109,page:‘superpage’}</script>
<meta http-equiv=X-UA-Compatible content=IE=EmulateIE7>
可以打開百度,右鍵查看源碼看下!我們可以看下文件頭是否存在這樣一行代碼!
這句話的意思是強制使用IE7模式來解析網頁代碼!
在這里送上幾種IE使用模式!
8 <metahttp-equiv=“X-UA-Compatible”content=“IE=8″>
2. Google Chrome Frame也可以讓IE用上Chrome的引擎:
9 <metahttp-equiv=“X-UA-Compatible”content=“chrome=1″/>
3.強制IE8使用IE7模式來解析
10 <metahttp-equiv=“X-UA-Compatible”content=“IE=EmulateIE7″><!– IE7 mode –>
11 //或者
12 <metahttp-equiv=“X-UA-Compatible”content=“IE=7″><!– IE7 mode –>
4.強制IE8使用IE6或IE5模式來解析
13 <metahttp-equiv=“X-UA-Compatible”content=“IE=6″><!– IE6 mode –>
14 <metahttp-equiv=“X-UA-Compatible”content=“IE=5″><!– IE5 mode –>
5.如果一個特定版本的IE支持所要求的兼容性模式多于一種,如:
15 <metahttp-equiv=“X-UA-Compatible”content=“IE=5; IE=8″/>
二.在網網站服務器上指定預設兼容性模式來解決這個辦法
當然如果服務器是自己的話,可以在服務器上定義一個自訂標頭來為它們的網站預設一個特定的文件兼容性模式。這個特定的方法取決于你的網站服務器。
錄入,下列的 web.config文件使Microsoft Internet Information Services (IIS)能定義一個自訂標頭以自動使用IE7 mode來編譯所有網頁。
另外還有一起其他的解決方案,例如google的
ie7 – js中是一個JavaScript庫(解決IE與W3C標準的沖突的JS庫),使微軟的Internet Explorer的行為像一個Web標準兼容的瀏覽器,支持更多的W3C標準,支持CSS2、CSS3選擇器。它修復了許多的HTML和CSS問題,并使得透明PNG在IE5、IE6下正確顯示。
使IE5,IE6兼容到IE7模式(推薦)
16 <!–[if lt IE 7]>
17 <script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE7.js” type=”text/javascript”></script>
18 <![endif]–>
使IE5,IE6,IE7兼容到IE8模式
19 <!–[if lt IE 8]>
20 <script src=”http://ie7-js.googlecode.com/svn/version/2.0(beta)/IE8.js” type=”text/javascript”></script>
21 <![endif]–>
使IE5,IE6,IE7,IE8兼容到IE9模式
22 <!–[if lt IE 9]>
23 <script src=”http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js”></script>
24 <![endif]–>
轉載請注明: 文章轉載自:愛思資源網 http://www.randomwithlife.com/show-11-463-1.html