I.IE8Compatibility View Overview
To solve the problem that new browsers are not compatible with old websites,IE8The browser adds a feature called "Compatibility View" to enable the webpageIE7OfCodeIn this way, most (but not all) web page problems caused by inconsistent code standards can be well solved.
Ii. Differences between "browser mode" and "document mode"
The Compatibility View involves two important functions: "browser mode ".Browser Mode"And" document mode"Document Mode", InIE8PressF12Open "Developer Tools". On the menu bar, you can see the switch menu of "browser mode" and "document mode". You can switchIE7/8And so on.
What is the difference between "browser mode" and "document mode?
"Browser mode" is used for switchingIEThe default document mode for the web page, the conditional remarks for different browsers, and the user agent sent to the website server (User-Agent) String value. The website can determine the browser version and installation function based on different user agent strings returned by the browser, so that different page content can be returned to different browsers.
By default,IE8The browser mode of isIE8. You can manually switch to different browser modes by clicking the Compatibility View button next to the address bar. InIE8Medium,IE8In the Compatibility ViewIE7Document mode to display web pages, and will send to the serverIE7User proxy string.
"Document mode" is used to specifyIEPage Layout Engine (Trident) To which version to parse and render the webpage code. Switching the document mode will cause the webpage to be refreshed, but the version number in the user agent string will not be changed or the webpage will not be re-downloaded from the server. When the browser mode is switched, the browser automatically switches to the corresponding document mode.
Generally, both versions must be set to the same version. But what if they are different? Or is there a difference in priority between the two?
See the followingMsdnPost: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
Extract the essence:
•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 wocould have ".
•We 've provided end-user and got ate/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 got Med 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. 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 sites ts 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.
There are two ways to makeIE8CompatibleIE7Mode. on the server sideProgramModify the document mode of a webpageDocument Mode, That is, throughMeta(X-UA-compatible Ie = emulateie7),Force the page to become compatibleIE7.
As follows:
<Head Runat= "Server">
<Meta HTTP-equiv= "X-UA-compatible" Content= "Ie = 7" />
<Title>Cest</Title>
</Head>
If you do not enter this sentence, it will be used by default.IE8.
The other is on the client, when the website has not been modifiedMetaIf the user installsIE8And clickCompatibility ViewButton.User Agent, That is, click the Compatibility View button, and then submitHTTPThe request header is rewrittenMsie7.0To disguise the clientIE7To send requests.
As follows:
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Trident/5.0; Server Load balancer ;. net CLR 2.0.50727 ;. net CLR 3.0.30729 ;. net CLR 3.5.30729 ;. net4.0c ;. net4.0e)
According toMsdnStatement, modifyMeta(X-UA-compatible Ie = emulateie7).Compatibility ViewIt can overwriteCompatibility View, That is to say, once the website version is releasedMeta,You can setCompatibility ViewTo automatically adapt to the new version.IE8Browser.
III.IE8Compatibility View(IE7 Mode)IndependentIE7Not exactly the same
SeeTechnet. MicrosoftPost:
What is Compatibility View?
Http://technet.microsoft.com/zh-cn/ff966533
Compatibility View is a feature of Windows Internet Explorer 8 that enables the browser to render a webpage nearly identically to the way that Windows Internet Explorer 7 wowould render it.
In Internet Explorer 8, Compatibility View changes how the browser interprets code that is written in CSS, HTML, and the Document Object Model (DOM) to try to match Internet Explorer 7. A site that a user views in Internet Explorer 8 Compatibility View is almost identical to a site that the user views in Internet Explorer 7. however, Compatibility View does not change how the browser interprets all code. for example, the changes in Internet Explorer 8 for how the browser handles ActiveX, the parser, Ajax, JavaScript, networking, and security might still cause compatibility issues. compatibility View does not change these behaviors.
In an enterprise environment, some areas have lower risk for compatibility issues. for example, Intranet Zone websites use Compatibility View by default. client Web applications that render by using the web browser control, or the weboc (Internet Explorer rendering engine ), also have a low risk for compatibility issues because Internet Explorer 8 defaults to a compatibility mode for the weboc. however, the default configuration settings for Compatibility View might not ensure complete compatibility. to determine if a website or web application is compatible with Internet Explorer 8, you shoshould test the website or web application.
For more information about the differences between Internet Explorer 8 Compatibility View and Internet Explorer 7, see the site compatibility and Internet Explorer 8 blog. for a list of what to check when you upgrade to Internet Explorer 8, see the Internet Explorer 8 readiness toolkit.
For more information about compatibility view, see the Internet Explorer team blog.
SeeMsdnPost:
1.Differences between IE8 Compatibility View and IE7
Http://blogs.msdn.com/ B /ie/archive/2009/03/12/site-compatibility-and-ie8.aspx
Excerpt:
We strive to make Compatibility View behave as much like IE7 as possible, but we do make exceptions. limits of these limits tions enable improved security and accessibility features immediately, even for sites that have not yet migrated to IE8 standards mode.
2.What exactly does Compatibility View do in IE8?
Http://webmasters.stackexchange.com/questions/2219/what-exactly-does-compatibility-view-do-in-ie8
Extract the essence:
Compatibility View renders the page as if it was Internet Explorer 7 (including JavaScript ). there are a few differences between IE8 with CV and pure IE7 but essential it is the same. if you really want the detail of what is going on then read just the facts: recap of Compatibility View from the IE msdn blog.
You can also force IE8 to use CV with this meta tag:
<Meta http-equiv = "X-UA-compatible" content = "Ie = emulateie7"/>
If you are having problems, I 'd suggest first checking you have a legitimate doctype in your HTML (the simplest one is <! Doctype HTML> which forces standards mode). That will solve 90% of your problems, especially with ie6.
Conclusion:IE8Compatible mode and independentIE7There are some differences between them. They are notIE8Contains a completeIE7.
Iv. Detailed differences
1.Cross Document Communication
Hacks enabling cross-domain, cross-document communication have been disabled for security reasons.
Solution:Use cross document messaging (xdm) to work around this change.
2.Extending the event object
IE exposes new properties for certain Ajax features such as cross document messaging (xdm), even in Compatibility View. adding custom properties to the event object can conflict with these new properties, such as "Source ".
Event. Source = myobject; // read-only in IE8
Solution: Change the names of conflicting custom properties to avoid collision.
Event. mysource = myobject;
3.Attribute Ordering
The ordering of attributes has changed, affecting the attributes collection as well as the values of innerhtml and outerhtml. Pages depending on a specific attribute ordering may break.
ATTR = Elm. attributes [1]; // may differ in IE8
Solution: Reference attributes by name as opposed to their position within the attributes collection.
ATTR = Elm. attributes ["ID"];
4.Setting unsupported CSS values
Assigning CSS values that were unsupported in IE7 but are supported in IE8 standards mode will not generate exceptions in IE8 Compatibility View. some sites use these exceptions to determine if a special value for a CSS property is supported or not.
Try
{
Elm. style. Display = "table-cell ";
} Catch (E)
{
// This executes in IE7,
// But not IE8, regardless of Mode
}
solution : short of Version Detection, this is a difficult issue to work around. if this behavior is essential to a page, updating the page to run in IE8 standards mode may be the best approach.