国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > 網頁設計 > 正文

IE8兼容視圖(IE7 mode)與獨立IE7的區別詳解

2024-08-30 08:34:39
字體:
來源:轉載
供稿:網友

一. IE8兼容視圖概述
為了解決新版瀏覽器不兼容舊網站的問題,IE8瀏覽器增加了一種叫做“兼容性視圖”的功能,可以讓網頁以IE7的代碼規范來顯示,這樣,就能夠很好的解決大部分(但不是全部)由于代碼標準不一致引起的網頁問題。
二.“瀏覽器模式”和“文檔模式”之間的區別
兼容性視圖涉及兩個重要的功能便是“瀏覽器模式browser mode”和“文檔模式document mode”,在IE8中按F12鍵,打開“開發人員工具”,在菜單欄中可以看到“瀏覽器模式”和“文檔模式”的切換菜單,其中可以選擇切換到IE7/8等不同的網頁模式。
那“瀏覽器模式”和“文檔模式”之間有什么區別呢?
“瀏覽器模式”用于切換IE針對該網頁的默認文檔模式、對不同版本瀏覽器的條件備注解析、發送給網站服務器的用戶代理(User-Agent)字符串的值。網站可以根據瀏覽器返回的不同用戶代理字符串判斷瀏覽器的版本和安裝的功能,這樣就可以向不同的瀏覽器返回不同的頁面內容。
默認情況下,IE8的瀏覽器模式為IE8。用戶可以通過單擊地址欄旁邊的兼容性視圖按鈕來手動切換到不同的瀏覽器模式。在IE8中,IE8兼容性視圖會以IE7文檔模式來顯示網頁,同時會向服務器發送IE7的用戶代理字符串。
“文檔模式”用于指定IE的頁面排版引擎(Trident)以哪個版本的方式來解析并渲染網頁代碼。切換文檔模式會導致網頁被刷新,但不會更改用戶代理字符串中的版本號,也不會從服務器重新下載網頁。切換瀏覽器模式的同時,瀏覽器也會自動切換到相應的文檔模式。
一般來說,兩者都要設置為同樣的版本,但是,如果不同又如何呢?或者說兩者是否有優先級區別呢?
請看下面的msdn帖子:Just The Facts: Recap of Compatibility View
http://blogs.msdn.com/b/ie/archive/2009/02/16/just-the-facts-recap-of-compatibility-view.aspx
精華摘抄:
•We’ve evangelized use of the X-UA-Compatible tag to websites unable to update to support IE8’s Standards mode. The tag allows a web author to declare the exact standards mode behavior for which their website works best – IE8 Standards (again, the default when no header is present) or IE7 Standards. For example, using the value ‘IE=EmulateIE7’ causes IE8 to display a website “as IE7 would have”.
•We’ve provided end-user and corporate / IT mitigations to the website compatibility problem under the umbrella term ‘Compatibility View’. ‘Compatibility View’ allows IE8 users to have a great experience even when visiting websites that haven’t yet performed either of the above two steps. It also helps IT organizations preserve compatibility with the large number of line-of-business websites that are Internet Explorer 7 capable today.
•Compatibility View and the X-UA-Compatible tag are not equivalent. Compatibility View is something you do on the client. It affects three things: the User Agent string, the Version Vector (used in evaluation of conditional comments), and what mode DOCTYPEs that trigger Standards map to – IE8 Standards or IE7 Standards. The X-UA-Compatible <META> tag / header is something you use in page content / server-side and, when present, completely overrides Compatibility View settings on the client. It affects two things: the Version Vector and what mode DOCTYPEs that trigger Standards map to. It can’t affect the UA string as it’s already too late to change that – the client’s already made the GET request to the server (and it contains a UA string). What this means to developers is that if your site pivots on the User Agent string, adding just the X-UA-Compatible tag (to cause IE8 to display your site in IE7 Standards mode) won’t make your website compatible – you’ll also need to update your User Agent string detection logic as well.
總結,有兩種方式可以使IE8兼容IE7模式,一是在服務器端,通過程序員控制修改網頁的文檔模式document mode,也就是通過Meta(X-UA-Compatible IE=EmulateIE7), 強制使頁面變為兼容IE7的頁面。
如下:

復制代碼
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 固原市| 姜堰市| 建昌县| 盐边县| 和田市| 铜陵市| 新竹县| 老河口市| 沈丘县| 高邑县| 鄂温| 青神县| 喀什市| 平顶山市| 吉安县| 襄樊市| 安国市| 绵阳市| 漳州市| 温州市| 堆龙德庆县| 长丰县| 云阳县| 于都县| 额尔古纳市| 林口县| 醴陵市| 扎囊县| 临西县| 精河县| 禹城市| 小金县| 远安县| 双辽市| 中宁县| 兴和县| 南陵县| 红安县| 靖远县| 武功县| 屯门区|