META tags and locks in future compatibility
Note: This document is a preliminary document and may be changed at any time.
For WEB developers, text compatibility is an important issue to consider. Windows Internet Explorer 8 introduces text compatibility mode, which allows Web developers to set the browser to display Web pages in the same way as older versions, allowing developers to choose the time to update.
This document describes the text compatibility mode that is supported by Windows Internet Explorer 8, and how you can use custom headers to implement these patterns on a per-page or per-site basis. After you implement the appropriate compatibility mode, you can ensure that the site is compatible with Windows Internet Explorer 8 and later.
Various compatibility modes
Windows Internet Explorer 8 supports multiple compatibility modes, which enable different supported features and affect how content is rendered. For example
IE5 mode renders content as if it were using the Quirks mode of Windows Internet Explorer 7, which is similar to how Windows Internet Explorer 5 displays content.
IE7 mode renders content regardless of whether the page contains <! The doctype> directive, like the standard mode for Windows Internet Explorer 7, is used.
EmulateIE7 mode notifies Windows Internet Explorer to use <! The doctype> directive determines how the content is rendered. Standard mode directives are displayed in Windows Internet Explorer 7 Standard mode, while Quirks mode directives are displayed in IE5 mode. Unlike IE7 mode, EmulateIE7 mode follows <! doctype> instructions. For most Web sites, it is the preferred compatibility mode.
IE8 mode maximizes support for industry standards (including the cascading style Sheets Level 2.1 specification and the world's selectors API, and can be limited in support of the world of cascading style She ETS Level 3 Specification (working draft).
Edge mode notifies Windows Internet Explorer to display content in the highest-level available mode, which in effect destroys lock mode. For Windows Internet Explorer 8, this is equivalent to the IE8 mode. if (assuming) a future version of Windows Internet Explorer supports a higher level of compatibility mode, pages set to Edge mode will appear in the highest levels of mode supported by that version, but when viewed with Windows Internet Explorer 8 , these same pages will still appear in the IE8 mode. Because it may be unexpected to render page content in a future release of Windows Internet Explorer, it is recommended that WEB developers use Edge mode only for test pages and other non-production activities.
Specify compatibility mode on a per-page basis
To specify a text pattern for a Web page, use the META element to include the x-ua-compatible http-equiv header in the page. The following example specifies EMULATEIE7 mode compatibility.
Html:
<!--Mimic Internet Explorer 7--
<title> my pages </title>
<meta http-equiv= "x-ua-compatible" content= "Ie=emulateie7"/>
<body>
<p> content here. </p>
</body>
The Content property specifies the mode of the page, for example, to mimic the behavior of Windows Internet Explorer 7, specify IE=EMULATEIE7. Similarly, you can specify Ie=5, ie=7, or ie=8 to select one of the compatibility modes. You can also specify Ie=edge to notify Windows Internet Explorer 8 to use the highest-level available mode.The x-ua-compatible header is not case sensitive, but it must appear in the header (Head section) of the Web page before all elements except TITLE and other META elements.
specify compatibility mode on a per-site basis
You can specify a text pattern for a Web site by using a WEB server to define a custom HTTP response header for the site. The HTTP response header is information that the WEB server attaches to a file that is sent to the browser in response to an HTTP request, which typically contains the date, size, and type of the file that was sent back.
The following documents describe the steps required to configure a WEB server to attach a custom HTTP response header to all Web pages. This causes Windows Internet Explorer 8 to use the specified text compatibility mode, such as EmulateIE7.
To implement META-switching on IIS
META Switch on Apache
If you specify the default text compatibility mode by using a Web server, you can override this setting by specifying additional text compatibility modes in specific Web pages. The pattern specified in the page takes precedence over the mode specified by the server.
Using scripts to determine text compatibility mode
To use Windows Internet Explorer 8 To determine the text compatibility mode for a Web page, use the Documentmode property of the Document object. For example, type the following into the address bar of Windows Internet Explorer 8 to display the text mode of the current Web page.
Javascript:alert (Document.documentmode);
The Documentmode property returns the value that corresponds to the text compatibility mode of the page. For example, if the selected page supports IE8 mode, Documentmode returns 8.
Note: The Compatmode property that is introduced in Windows Internet Explorer 6 is not supported and is replaced by the Documentmode attribute that is introduced in Windows Internet Explorer 8. Applications that are currently using Compatmode can still run in Windows Internet Explorer 8, but they have been updated to use Documentmode.
If you want to use JavaScript to determine the compatibility mode of text, include code that supports older versions of Windows Internet Explorer, as shown in the following example.
Jscript:
engine = NULL;
if (Window.navigator.appName = = "Microsoft Internet Explorer") {
This is an IE browser. What mode is the engine in?
if (Document.documentmode)//IE8
else//IE 5-7 {
engine = 5; Assumed to be quirks mode; Unless otherwise proven to be another pattern .
if (document.compatmode) {
if (Document.compatmode = = "Css1compat")
engine = 7; Standard mode
}
}
Engine variables now contain text compatibility mode.
}
The Document object used here represents an HTML document in a given browser window, which you can use to examine, modify, or add content to the document and to manipulate events in that document.
Using conditional annotations to determine text compatibility mode
If you only need to adapt to Windows Internet Explorer, The following code example demonstrates how to use conditional comments for the current or previous version.
Html:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 strict//en" >
<title> test Page </title>
<meta http-equiv= "x-ua-compatible" content= "ie=8"/>
<!--[if GTE IE 8]>
<style type= "Text/css" >
Body {color: #0000ff;}
</style>
<! [endif]-->
<!--[If Lt IE 8]>
<style type= "Text/css" >
Body {color: #000000; Background-color: #ffffff;}
</style>
<! [endif]-->
<body>
<!--[if GTE IE 8]> the 2nd chapter. <! [endif]--> Chapter II You will see any version of the text.
</body>
X-ua-compatible is a setting for IE8, and for browsers other than IE8, this difference differs from content= "ie=7" in whether the page contains <! The doctype> directive, like the standard mode for Windows Internet Explorer 7, is used. and content= "IE=EMULATEIE7" mode follows <! doctype> instructions. For most Web sites, it is the preferred compatibility mode.
Currently IE8 is still in beta, so in order to avoid making the page under IE8 error, it is recommended to directly IE8 using IE7 to render. That is, add the following code directly to the META tag in the header of the page:
<meta http-equiv= "x-ua-compatible" content= "ie=7"/> so we can make the page behave normally in IE8!
<meta http-equiv=x-ua-compatible content=ie=emulateie7>