2010年4月29日星期四

定义Internet Explorer文档兼容性

更新日期: 2009 年 2 月
文档兼容性可定义 Internet Explorer 呈现网页的方式。 本文将介绍文档兼容性、如何为网页指定文档兼容性模式以及如何确定网页的文档模式。

简介

为了帮助确保您的网页在将来的 Internet Explorer 版本中具有一致的外观,Internet Explorer 8 引入了文档兼容性。 文档兼容性是对 Microsoft Internet Explorer 6 中引入的兼容性模式的扩展,使您可以选择 Internet Explorer 用于显示网页的特定呈现模式。
本文将说明文档兼容性的必要性,列出对近来的 Internet Explorer 版本可用的文档兼容性模式,并演示如何选择特定的兼容性模式。

了解文档兼容性的必要性

Internet Explorer 的每个主要版本中都会添加一些功能,旨在使浏览器更易于使用、提高安全性以及更紧密地支持行业标准。 随着 Internet Explorer 的功能不断增加,将会出现较早的网站可能无法正常显示的风险。
为了最大程度地降低这种风险,Internet Explorer 6 允许 Web 开发人员选择 Internet Explorer 用来解释和显示其网页的方式。 默认为“Quirks 模式”;在这种模式下,将按照使用较旧的浏览器版本查看网页的方式来显示网页。 “标准模式”(也称为“严格模式”)的特点是可提供对行业标准的最大支持;但是,若要利用此增强的支持,网页中需要包括适当的  指令。
如果某个站点未包括 指令,则 Internet Explorer 6 将使用 Quirks 模式显示该站点。 如果某个站点包含有浏览器未能识别的有效 指令,则 Internet Explorer 6 将使用 Internet Explorer 6 标准模式显示该站点。 由于已经包含 指令的站点很少,因此兼容性模式切换极为成功。 这样使 Web 开发人员能够选择最佳时间将其站点迁移到标准模式。
随着时间的推移,许多站点都开始依赖标准模式。 这些站点同时还开始使用 Internet Explorer 6 的功能和行为来检测 Internet Explorer。 例如,Internet Explorer 6 并不支持 通用选择器(可能为英文网页);而某些网站将此用作为 Internet Explorer 提供特定内容的方式。
Internet Explorer 7 提供了通用选择器支持等新功能,旨在更全面地支持行业标准。 由于 指令仅支持 Quirks 模式和标准模式这两种设置,因此 Internet Explorer 7 标准模式替换了 Internet Explorer 6 标准模式。
结果,依赖于 Internet Explorer 6 标准模式的行为的站点(如缺乏对通用选择器的支持)将无法检测到新版本的浏览器。 因此,Internet Explorer 特定的内容不会提供给 Internet Explorer 7,并且这些站点不会按预期显示。 由于 Internet Explorer 7 仅支持两种兼容性模式,因此将会迫使受影响站点的所有者更新其站点以支持 Internet Explorer 7。
与任何早期浏览器版本相比,Internet Explorer 8 对行业标准提供了更加紧密的支持。 因此,针对旧版本的浏览器设计的站点可能不会按预期显示。 为了帮助减轻任何问题,Internet Explorer 8 引入了文档兼容性的概念,从而允许您指定站点所支持的 Internet Explorer 版本。 文档兼容性在 Internet Explorer 8 中添加了新的模式;这些模式将告诉浏览器如何解释和呈现网站。 如果您的站点在 Internet Explorer 8 中无法正确显示,则可以更新该站点以支持最新的 Web 标准(首选方式),也可以强制 Internet Explorer 8 按照在旧版本的浏览器中查看站点的方式来显示内容。 通过使用 meta 元素将 X-UA-Compatible 标头添加到网页中,可以实现这一点。
这将允许您选择何时更新站点以支持由 Internet Explorer 8 支持的新功能。

了解文档兼容性模式

Internet Explorer 8 支持很多文档兼容性模式,这些模式启用不同的功能并可影响内容的显示方式。
  • “模仿 IE8”模式将告诉 Internet Explorer 使用 指令来确定如何呈现内容。 标准模式指令将以 Internet Explorer 8 标准模式显示,而 Quirks 模式指令将以 IE5 模式显示。 与 IE8 模式不同,“模仿 IE8”模式遵循 指令。
  • “模仿 IE7”模式将告诉 Internet Explorer 使用 指令来确定如何呈现内容。 标准模式指令以 Internet Explorer 7 标准模式显示,而 Quirks 模式指令以 IE5 模式显示。 与 IE7 模式不同,“模仿 IE7 模式”遵循 指令。 对于很多网站来说,这是首选的兼容性模式。
  • IE5 模式呈现内容的方式如同使用了 Internet Explorer 7 的 Quirks 模式来显示内容,这与 Internet Explorer 5 显示内容的方式非常相似。
  • 无论页面是否包含 指令,IE7 模式呈现内容的方式均如同使用了 Internet Explorer 7 的标准模式来显示内容。
  • IE8 模式可最大程度地支持行业标准(包括 W3C 级联样式表级别 2.1 规范(可能为英文网页)  万维网链接 和 W3C 选择器 API(可能为英文网页)  万维网链接),并提供对W3C 级联样式表级别 3 规范(工作草案)(可能为英文网页)  万维网链接 的有限支持。
  • Edge 模式将告诉 Internet Explorer 以可用的最高级别模式显示内容。 对于 Internet Explorer 8,这等同于 IE8 模式。 假设 Internet Explorer 的将来版本支持更高级别的兼容性模式,那么,设置为 Edge 模式的页面将以该版本支持的最高级别的模式显示。 当使用 Internet Explorer 8 查看时,这些相同的页面仍会以 IE8 模式显示。
由于 Edge 模式的文档使用查看网页所用的 Internet Explorer 版本可用的最高级别模式来显示网页,因此,建议仅将 Edge 模式用于测试页面和其他非生产活动。

指定文档兼容性模式

若要为网页指定文档模式,请使用 meta 元素,以在网页中包含 X-UA-Compatible  http-equiv 标头。 以下示例指定“模仿 IE7”模式兼容性。
  




Content goes here.
content 属性指定页面的模式;若要模仿 Internet Explorer 7 的行为,请指定“IE=EmulateIE7”。 指定“IE=5”、“IE=7”或“IE=8”可选择相应的兼容性模式。 还可以指定“IE=edge”以告诉 Internet Explorer 8 使用可用的最高级别模式。
X-UA-compatible 标头不区分大小写;不过,它必须显示在网页中除 title 元素和其他 meta 元素以外的所有其他元素之前的标头(HEAD 节(可能为英文网页))中。

配置 Web 服务器以指定默认兼容性模式

网站管理员可以通过定义站点的自定义标头,将其站点配置为默认采用特定的文档兼容性模式。 具体过程将依您的 Web 服务器而定。 例如,通过以下 web.config 文件,可以让 Microsoft Internet Information Services (IIS) 定义一个自定义标头,以便自动按照 IE7 模式呈现所有页面。









如果使用 Web 服务器指定了默认的文档兼容性模式,则可通过在特定的网页中指定不同的文档兼容性模式来覆盖默认设置。 在网页中指定的模式优先于由 Web 服务器指定的模式。
有关如何指定自定义标头的信息,请查看特定的 Web 服务器的文档。 或者,访问以下网页以获取详细信息:

确定文档兼容性模式

若要确定使用 Internet Explorer 8 的网页的文本兼容性模式,请使用 document 对象的 documentMode 属性。 例如,将以下内容键入到 Windows Internet Explorer 8 的地址栏中,可显示当前网页的文档模式。
javascript:alert(document.documentMode);
documentMode 属性将返回一个与页面的文档兼容性模式相对应的数值。 例如,如果某个页面已选择支持 IE8 模式,则 documentMode 将返回值 8。
在 Internet Explorer 6 中引入的 compatMode 属性已被弃用,取而代之的是在 Internet Explorer 8 中引入的 documentMode 属性。当前依赖于 compatMode 的应用程序仍然可以在 Internet Explorer 8 中运行;但是,应将这些应用程序更新为使用 documentMode。
如果希望使用 JavaScript 来确定文档的兼容性模式,则应包含支持 Internet Explorer 旧版本的代码,如以下示例中所示。
engine = null;
if (window.navigator.appName == "Microsoft Internet Explorer")
{
// This is an IE browser. What mode is the engine in?
if (document.documentMode) // IE8
engine = document.documentMode;
else // IE 5-7
{
engine = 5; // Assume quirks mode unless proven otherwise
if (document.compatMode)
{
if (document.compatMode == "CSS1Compat")
engine = 7; // standards mode
}
}
// the engine variable now contains the document compatibility mode.
}

了解 content 属性值

content 属性的使用很灵活,它可以接受除前面所述的值之外的值。 这样,您就能够更好地控制 Internet Explorer 显示网页的方式。 例如,可以将 content 属性设置为IE=7.5。 当您如此设置之后,Internet Explorer 会尝试将该值转换为 版本矢量(可能为英文网页),并选择与转换结果最接近的模式。 在本例中,Internet Explorer 将会设置为 IE7 模式。 以下示例显示了为其他值选择的模式(如果不存在其他缓解因素)。







注意  上一个示例显示了各个 content 值的结果。 实际上,Internet Explorer 仅遵循网页中的第一个 X-UA-Compatible 标头。
还可以使用 content 属性来指定多个文档兼容性模式;这将有助于确保网页在将来的浏览器版本中显示一致。 若要指定多个文档模式,应设置 content 属性以标识要使用的各个模式。 各个模式之间使用分号分隔。
如果某个特定的 Internet Explorer 版本支持多个请求的兼容性模式,则该版本将使用标头的 content 属性中列出的可用的最高级别模式。 可以利用这一原理来排除特定的兼容性模式,但不建议这样做。 例如,下面的标头排除了 IE7 模式。

控制默认呈现

当 Internet Explorer 8 遇到未包含 X-UA-Compatible 标头的网页时,它将使用 指令来确定如何显示该网页。 如果该指令丢失或未指定基于标准的文档类型,则 Internet Explorer 8 将以 IE5 模式(Quirks 模式)显示该网页。
如果 指令指定了基于标准的文档类型,则 Internet Explorer 8 将以 IE8 模式显示该网页,但出现以下情况时除外:
  • 为该网页启用了兼容性视图。
  • 该网页是在 Intranet 区域中加载的,并且已将 Internet Explorer 8 配置为使用兼容性视图来显示 Intranet 区域中的网页。
  • 已将 Internet Explorer 8 配置为使用兼容性视图来显示所有网站。
  • 已将 Internet Explorer 8 配置为使用兼容性视图列表(其中指定了一组始终使用兼容性视图显示的网站)。
  • 已使用开发人员工具覆盖在该网页中指定的设置。
  • 该网页遇到了页面布局错误,并且已将 Internet Explorer 8 配置为,通过在兼容性视图中重新打开网页来自动从此类错误中恢复。
注意  如果将 Internet Explorer 配置为使用兼容性视图加载 Intranet 页面,Internet Explorer 将对使用 localhost 地址或 环回地址(可能为英文网页)加载的页面引发异常。 如果 指令指定基于标准的文档类型,则将以 IE8 模式显示使用这些技术加载的页面。
此外,可以使用下面的注册表项来控制 Internet Explorer 对未包含 X-UA-Compatible 标头的页面的处理方式。
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
     SOFTWARE
          Microsoft
               Internet Explorer
                    Main
                         FeatureControl
                              FEATURE_BROWSER_EMULATION
                                   iexplore.exe = (DWORD)
DWORD 值必须等于下列值之一。
说明
7000包含基于标准的 指令的页面将以 IE7 模式显示。
8000包含基于标准的 指令的页面以 IE8 模式显示。
8888页面始终以 IE8 模式显示,而不考虑 指令。 (这可绕过前面列出的例外情况。)
默认情况下,承载 WebBrowser 控件(可能为英文网页)的应用程序将以 IE7 模式打开基于标准的页面,除非页面中包含适当的 X-UA-Compatible 标头。 通过将应用程序可执行文件的名称添加到 FEATURE_BROWSER_EMULATION 功能控制项中,并相应地设置值,可以更改打开模式。

总结

对于 Web 设计人员来说,兼容性是一个要考虑的重要问题。 尽管最好是创建不依赖于 Web 浏览器的特定行为或功能的站点,但有时这样做是不可能的。 文档兼容性模式将网页与 Internet Explorer 特定版本的行为相关联。
使用 X-UA-Compatible 标头可指定页面支持的 Internet Explorer 版本。 使用 document.documentMode 可确定网页的兼容性模式。
通过选择支持特定的 Internet Explorer 版本,可有助于确保页面在将来的浏览器版本中能够显示一致。

相关主题

定义Internet Explorer文档兼容性

更新日期: 2009 年 2 月
文档兼容性可定义 Internet Explorer 呈现网页的方式。 本文将介绍文档兼容性、如何为网页指定文档兼容性模式以及如何确定网页的文档模式。

简介

为了帮助确保您的网页在将来的 Internet Explorer 版本中具有一致的外观,Internet Explorer 8 引入了文档兼容性。 文档兼容性是对 Microsoft Internet Explorer 6 中引入的兼容性模式的扩展,使您可以选择 Internet Explorer 用于显示网页的特定呈现模式。
本文将说明文档兼容性的必要性,列出对近来的 Internet Explorer 版本可用的文档兼容性模式,并演示如何选择特定的兼容性模式。

了解文档兼容性的必要性

Internet Explorer 的每个主要版本中都会添加一些功能,旨在使浏览器更易于使用、提高安全性以及更紧密地支持行业标准。 随着 Internet Explorer 的功能不断增加,将会出现较早的网站可能无法正常显示的风险。
为了最大程度地降低这种风险,Internet Explorer 6 允许 Web 开发人员选择 Internet Explorer 用来解释和显示其网页的方式。 默认为“Quirks 模式”;在这种模式下,将按照使用较旧的浏览器版本查看网页的方式来显示网页。 “标准模式”(也称为“严格模式”)的特点是可提供对行业标准的最大支持;但是,若要利用此增强的支持,网页中需要包括适当的  指令。
如果某个站点未包括 指令,则 Internet Explorer 6 将使用 Quirks 模式显示该站点。 如果某个站点包含有浏览器未能识别的有效 指令,则 Internet Explorer 6 将使用 Internet Explorer 6 标准模式显示该站点。 由于已经包含 指令的站点很少,因此兼容性模式切换极为成功。 这样使 Web 开发人员能够选择最佳时间将其站点迁移到标准模式。
随着时间的推移,许多站点都开始依赖标准模式。 这些站点同时还开始使用 Internet Explorer 6 的功能和行为来检测 Internet Explorer。 例如,Internet Explorer 6 并不支持 通用选择器(可能为英文网页);而某些网站将此用作为 Internet Explorer 提供特定内容的方式。
Internet Explorer 7 提供了通用选择器支持等新功能,旨在更全面地支持行业标准。 由于 指令仅支持 Quirks 模式和标准模式这两种设置,因此 Internet Explorer 7 标准模式替换了 Internet Explorer 6 标准模式。
结果,依赖于 Internet Explorer 6 标准模式的行为的站点(如缺乏对通用选择器的支持)将无法检测到新版本的浏览器。 因此,Internet Explorer 特定的内容不会提供给 Internet Explorer 7,并且这些站点不会按预期显示。 由于 Internet Explorer 7 仅支持两种兼容性模式,因此将会迫使受影响站点的所有者更新其站点以支持 Internet Explorer 7。
与任何早期浏览器版本相比,Internet Explorer 8 对行业标准提供了更加紧密的支持。 因此,针对旧版本的浏览器设计的站点可能不会按预期显示。 为了帮助减轻任何问题,Internet Explorer 8 引入了文档兼容性的概念,从而允许您指定站点所支持的 Internet Explorer 版本。 文档兼容性在 Internet Explorer 8 中添加了新的模式;这些模式将告诉浏览器如何解释和呈现网站。 如果您的站点在 Internet Explorer 8 中无法正确显示,则可以更新该站点以支持最新的 Web 标准(首选方式),也可以强制 Internet Explorer 8 按照在旧版本的浏览器中查看站点的方式来显示内容。 通过使用 meta 元素将 X-UA-Compatible 标头添加到网页中,可以实现这一点。
这将允许您选择何时更新站点以支持由 Internet Explorer 8 支持的新功能。

了解文档兼容性模式

Internet Explorer 8 支持很多文档兼容性模式,这些模式启用不同的功能并可影响内容的显示方式。
  • “模仿 IE8”模式将告诉 Internet Explorer 使用 指令来确定如何呈现内容。 标准模式指令将以 Internet Explorer 8 标准模式显示,而 Quirks 模式指令将以 IE5 模式显示。 与 IE8 模式不同,“模仿 IE8”模式遵循 指令。
  • “模仿 IE7”模式将告诉 Internet Explorer 使用 指令来确定如何呈现内容。 标准模式指令以 Internet Explorer 7 标准模式显示,而 Quirks 模式指令以 IE5 模式显示。 与 IE7 模式不同,“模仿 IE7 模式”遵循 指令。 对于很多网站来说,这是首选的兼容性模式。
  • IE5 模式呈现内容的方式如同使用了 Internet Explorer 7 的 Quirks 模式来显示内容,这与 Internet Explorer 5 显示内容的方式非常相似。
  • 无论页面是否包含 指令,IE7 模式呈现内容的方式均如同使用了 Internet Explorer 7 的标准模式来显示内容。
  • IE8 模式可最大程度地支持行业标准(包括 W3C 级联样式表级别 2.1 规范(可能为英文网页)  万维网链接 和 W3C 选择器 API(可能为英文网页)  万维网链接),并提供对W3C 级联样式表级别 3 规范(工作草案)(可能为英文网页)  万维网链接 的有限支持。
  • Edge 模式将告诉 Internet Explorer 以可用的最高级别模式显示内容。 对于 Internet Explorer 8,这等同于 IE8 模式。 假设 Internet Explorer 的将来版本支持更高级别的兼容性模式,那么,设置为 Edge 模式的页面将以该版本支持的最高级别的模式显示。 当使用 Internet Explorer 8 查看时,这些相同的页面仍会以 IE8 模式显示。
由于 Edge 模式的文档使用查看网页所用的 Internet Explorer 版本可用的最高级别模式来显示网页,因此,建议仅将 Edge 模式用于测试页面和其他非生产活动。

指定文档兼容性模式

若要为网页指定文档模式,请使用 meta 元素,以在网页中包含 X-UA-Compatible  http-equiv 标头。 以下示例指定“模仿 IE7”模式兼容性。

  


Content goes here.

content 属性指定页面的模式;若要模仿 Internet Explorer 7 的行为,请指定“IE=EmulateIE7”。 指定“IE=5”、“IE=7”或“IE=8”可选择相应的兼容性模式。 还可以指定“IE=edge”以告诉 Internet Explorer 8 使用可用的最高级别模式。
X-UA-compatible 标头不区分大小写;不过,它必须显示在网页中除 title 元素和其他 meta 元素以外的所有其他元素之前的标头(HEAD 节(可能为英文网页))中。

配置 Web 服务器以指定默认兼容性模式

网站管理员可以通过定义站点的自定义标头,将其站点配置为默认采用特定的文档兼容性模式。 具体过程将依您的 Web 服务器而定。 例如,通过以下 web.config 文件,可以让 Microsoft Internet Information Services (IIS) 定义一个自定义标头,以便自动按照 IE7 模式呈现所有页面。











如果使用 Web 服务器指定了默认的文档兼容性模式,则可通过在特定的网页中指定不同的文档兼容性模式来覆盖默认设置。 在网页中指定的模式优先于由 Web 服务器指定的模式。
有关如何指定自定义标头的信息,请查看特定的 Web 服务器的文档。 或者,访问以下网页以获取详细信息:

确定文档兼容性模式

若要确定使用 Internet Explorer 8 的网页的文本兼容性模式,请使用 document 对象的 documentMode 属性。 例如,将以下内容键入到 Windows Internet Explorer 8 的地址栏中,可显示当前网页的文档模式。

javascript:alert(document.documentMode);

documentMode 属性将返回一个与页面的文档兼容性模式相对应的数值。 例如,如果某个页面已选择支持 IE8 模式,则 documentMode 将返回值 8。
在 Internet Explorer 6 中引入的 compatMode 属性已被弃用,取而代之的是在 Internet Explorer 8 中引入的 documentMode 属性。当前依赖于 compatMode 的应用程序仍然可以在 Internet Explorer 8 中运行;但是,应将这些应用程序更新为使用 documentMode。
如果希望使用 JavaScript 来确定文档的兼容性模式,则应包含支持 Internet Explorer 旧版本的代码,如以下示例中所示。

engine = null;
if (window.navigator.appName == "Microsoft Internet Explorer")
{
// This is an IE browser. What mode is the engine in?
if (document.documentMode) // IE8
engine = document.documentMode;
else // IE 5-7
{
engine = 5; // Assume quirks mode unless proven otherwise
if (document.compatMode)
{
if (document.compatMode == "CSS1Compat")
engine = 7; // standards mode
}
}
// the engine variable now contains the document compatibility mode.
}

了解 content 属性值

content 属性的使用很灵活,它可以接受除前面所述的值之外的值。 这样,您就能够更好地控制 Internet Explorer 显示网页的方式。 例如,可以将 content 属性设置为IE=7.5。 当您如此设置之后,Internet Explorer 会尝试将该值转换为 版本矢量(可能为英文网页),并选择与转换结果最接近的模式。 在本例中,Internet Explorer 将会设置为 IE7 模式。 以下示例显示了为其他值选择的模式(如果不存在其他缓解因素)。

    




注意  上一个示例显示了各个 content 值的结果。 实际上,Internet Explorer 仅遵循网页中的第一个 X-UA-Compatible 标头。
还可以使用 content 属性来指定多个文档兼容性模式;这将有助于确保网页在将来的浏览器版本中显示一致。 若要指定多个文档模式,应设置 content 属性以标识要使用的各个模式。 各个模式之间使用分号分隔。
如果某个特定的 Internet Explorer 版本支持多个请求的兼容性模式,则该版本将使用标头的 content 属性中列出的可用的最高级别模式。 可以利用这一原理来排除特定的兼容性模式,但不建议这样做。 例如,下面的标头排除了 IE7 模式。


控制默认呈现

当 Internet Explorer 8 遇到未包含 X-UA-Compatible 标头的网页时,它将使用 指令来确定如何显示该网页。 如果该指令丢失或未指定基于标准的文档类型,则 Internet Explorer 8 将以 IE5 模式(Quirks 模式)显示该网页。
如果 指令指定了基于标准的文档类型,则 Internet Explorer 8 将以 IE8 模式显示该网页,但出现以下情况时除外:
  • 为该网页启用了兼容性视图。
  • 该网页是在 Intranet 区域中加载的,并且已将 Internet Explorer 8 配置为使用兼容性视图来显示 Intranet 区域中的网页。
  • 已将 Internet Explorer 8 配置为使用兼容性视图来显示所有网站。
  • 已将 Internet Explorer 8 配置为使用兼容性视图列表(其中指定了一组始终使用兼容性视图显示的网站)。
  • 已使用开发人员工具覆盖在该网页中指定的设置。
  • 该网页遇到了页面布局错误,并且已将 Internet Explorer 8 配置为,通过在兼容性视图中重新打开网页来自动从此类错误中恢复。
注意  如果将 Internet Explorer 配置为使用兼容性视图加载 Intranet 页面,Internet Explorer 将对使用 localhost 地址或 环回地址(可能为英文网页)加载的页面引发异常。 如果 指令指定基于标准的文档类型,则将以 IE8 模式显示使用这些技术加载的页面。
此外,可以使用下面的注册表项来控制 Internet Explorer 对未包含 X-UA-Compatible 标头的页面的处理方式。
HKEY_LOCAL_MACHINE (or HKEY_CURRENT_USER)
     SOFTWARE
          Microsoft
               Internet Explorer
                    Main
                         FeatureControl
                              FEATURE_BROWSER_EMULATION
                                   iexplore.exe = (DWORD)
DWORD 值必须等于下列值之一。
说明
7000包含基于标准的 指令的页面将以 IE7 模式显示。
8000包含基于标准的 指令的页面以 IE8 模式显示。
8888页面始终以 IE8 模式显示,而不考虑 指令。 (这可绕过前面列出的例外情况。)
默认情况下,承载 WebBrowser 控件(可能为英文网页)的应用程序将以 IE7 模式打开基于标准的页面,除非页面中包含适当的 X-UA-Compatible 标头。 通过将应用程序可执行文件的名称添加到 FEATURE_BROWSER_EMULATION 功能控制项中,并相应地设置值,可以更改打开模式。

总结

对于 Web 设计人员来说,兼容性是一个要考虑的重要问题。 尽管最好是创建不依赖于 Web 浏览器的特定行为或功能的站点,但有时这样做是不可能的。 文档兼容性模式将网页与 Internet Explorer 特定版本的行为相关联。
使用 X-UA-Compatible 标头可指定页面支持的 Internet Explorer 版本。 使用 document.documentMode 可确定网页的兼容性模式。
通过选择支持特定的 Internet Explorer 版本,可有助于确保页面在将来的浏览器版本中能够显示一致。

相关主题

2010年4月26日星期一

几个很好的分析chrome的博客

大坡3D软件开发
http://blog.csdn.net/caimouse/category/458770.aspx

venus神庙
http://www.cnblogs.com/duguguiyu/tag/Chrome/

chrome技术文档列表

豆瓣的日记翻起来不方便,现在弄一个整体列表方便自己差查询。
chrome窗口焦点管理系统 http://www.douban.com/note/32607279/
chrome之TabContents http://www.douban.com/note/32671779/
chrome之事件通知模型 http://www.douban.com/note/32864881/
在 chrome中添加IE兼容窗口的策略 http://www.douban.com/note/32879983/
 chrome之扩展系统(Extensions) http://www.douban.com/note/32954421/
 TabContents创建苍白无味的流程 http://www.douban.com/note/32759140/
chrome之窗口布局 http://www.douban.com/note/32994699/
浏览器应该拥有的功能 http://www.douban.com/note/33171410/
IE编程, 浏览器开发技术 http://www.douban.com/note/33231183/
在 chrome添加IE窗口技术文档(不使用插件) http://www.douban.com/note/33242308/
打开一个HTML页面的几种情况 http://www.douban.com/note/33279247/
WIBKIT技术资料 http://www.douban.com/note/33382204/
WebKit学习要点 http://www.douban.com/note/33443700/
WEBKIT之WebView http://www.douban.com/note/33440271/
WindowOpenDisposition 几种打开位置说明 http://www.douban.com/note/34367370/
TabContents,NavigationController,RenderViewHostManager 的三角关系 http://www.douban.com/note/34096428/
NavigationEntry说明 http://www.douban.com/note/34563692/
hrome 中相关技术术语解释 http://www.douban.com/note/35113604/
chrome添加IE策略的具体技术细节 http://www.douban.com/note/35072705/
IE策略需要完成的细节问题列表 http://www.douban.com/note/36118152/
chrome焦点管理 http://www.douban.com/note/36785783/
sunchrome第一次发布计划以及功能 http://www.douban.com/note/36925017/
chrome中的数据库 http://www.douban.com/note/37122007/

2010年4月9日星期五

IE8: Powerful New Developer Features


Powerful New Developer Features









Accelerators

Accelerators are contextual services that quickly access a service from any webpage. Users often copy and paste from one webpage to another, but Internet Explorer 8 Accelerators make this easier.
Accelerators enable users to find information without leaving the current webpage. For example: a user is interested in a restaurant and wants to see its location. By selecting the address, the user can view a preview of the map, with an option to click to a full webpage with additional information from a mapping service.
Activities Screenshot

Accelerators can also be used to send information to a service. For instance: a user reads an interesting article and wants to blog about a portion of the article. The user can select a portion of the article and use a blog Accelerator to navigate to the user's blog site with the selected text already available in the Edit field.
Users can access an Accelerator by simply selecting content and clicking the button that appears next to the selection. Alternatively, users can access Accelerators from the context menu for selections, links, and the current webpage. Accelerators for the current webpage are also available from All Accelerators on the Page menu.
Accelerators are services that the user can install and manage. Users can install them from the Internet Explorer Gallery or through any website that advertises Accelerators.
Accelerators are described by an XML file that provides the interface of how the browser should communicate with the service through URL templates. Web-based services should take advantage of XML-based Accelerators, since they are easy to create, test, and deploy to users.
This is a simple sample that shows a map Accelerator that you can host on a website:
Create the Accelerator XML file: Copy the sample code below to a text editor and save it as "GetMap.xml". The code below describes the functionality of the Accelerator.

 
  http://maps.live.com
 
    Map with Windows Live
    http://www.live.com/favicon.ico
 

 
   
     
       
       
       
       
       

     
       
     

   

 
Host the install button by adding this code example to the website on which you want to advertise the Accelerator.

Test the accelerator:
  1. Install the Accelerator by clicking Install on your website. This launches the installation dialog box.
  2. Select the Make this my default provider check box. This sets the Accelerator to appear in the top listing.
  3. Go to a site that contains a street address.
  4. Select the address and click the button that appears next the mouse cursor. (Alternatively, you can right-click to get the context menu.)
  5. Hover over the Map with Live Maps Accelerator. This displays the preview of the map Accelerator.
  6. Click the Map with Live Maps Accelerator. This navigates to the map website in a new tab.
For more information, see OpenService Accelerators Developer Guide.
return to top


Web Slices

Web Slices is a new feature enabling websites to connect to their users by allowing them to subscribe to content directly within a webpage. Web Slices behave just like RSS feeds; users can subscribe to get updates and be notified of changes.
A Web Slice is a section of a webpage that is treated like a subscribable item, just like a feed. To enable a Web Slice on your website, annotate your webpage with class names for the title, description, and other subscribable properties.
Users can discover Web Slices within a webpage and add them to the Favorites bar, a dedicated row below the Address bar enabling easy access to links. Internet Explorer 8 subscribes to the webpage, detects changes in the Web Slice, and notifies the user of updates. Users can preview these updates directly from the Favorites bar and click through to the website to get more information.

WebSlice Authoring

Web Slices are enabled by adding HTML annotations directly to the webpage. Web Slices use a combination of the hAtom Microformat and the Web Slice format to describe a subscribable portion of a webpage.
The Basics
The basic properties of a Web Slice are the Web Slice container, title, and content.

WebSlice

  • Required
  • Uses class name hslice
  • The Web Slice element must include an ID
  • Represents the entire region of a Web Slice that contains the title, description, and other WebSlice properties

Entry Title

  • Required
  • Uses class name entry-title as defined in the hAtom Microformat
  • There can be multiple instances of Entry Title

Entry Content

  • Optional
  • Uses class name entry-content as defined in the hAtom Microformat
  • If the Entry Content is missing, assume it is an empty string
  • There can be multiple instances of Entry Content
This is an example of how to mark up an auction item with the link, title, and description properties
http://www.auction.microsoft.com/item

 
"entry-title">item - $66.00

 
"entry-content">high bidder:buyer1
    …
 

For more information, please see Subscribing to Content with Web Slices and Web Slice Style Guide.

return to top


CSS 2.1 Compliance

Style Sheets

Cascading Style Sheets (CSS) is a simple mechanism for adding style (such as fonts, colors, spacing, positioning) to web documents. Before the introduction of CSS, stylistic properties were set directly within HTML with different attributes. With CSS, authors can separate a page's data (specified in HTML) from the display logic, thus improving markup organization and facilitating easier site maintenance.
The W3C CSS working group has made great strides toward converging on a final specification for CSS 2.1. At the time of this writing, the specification status is "Candidate Recommendation." The main goal of this effort is to enable web developers and designers to write their pages once and have them render properly in many browsers. The new Developer Tools included with Internet Explorer 8 will also help in this endeavor. Internet Explorer 8 supports the latest feature set as defined in the specification.
While one of the main goals for Internet Explorer 8 is CSS 2.1 compliance, it is also forward-looking toward CSS3. CSS 3 is the next step in the evolution of Cascading Style Sheets, and unlike CSS 2.1, which consists of one single document, the CSS 3 specification is broken down into different modules to speed up the process of converging on clear specifications and implementations of different features. Additionally, CSS 3 hopes to further clarify some of the ambiguities in the CSS 2.1 specification while providing new features to web authors. Internet Explorer 8 hopes to implement some of the most requested CSS 3 features by web developers and designers.
See CSS Improvements in Internet Explorer 8 for more information.
return to top


Data URI Support

Data URIs offer web developers the opportunity to embed small external resources (like CSS files or images) directly into a URL on a webpage:
Image fed from data urldata:image/png;base64,iVBORw0KGgoAAA..." />
The primary use case for data URIs is the encapsulation of a binary file inside an URL (a stylesheet or image). Because the binary file can be represented inline as a string, it may be saved to the local store and retrieved at a later time without needing to fetch anything from the network.
Data URIs also offer an alternative to traditional URIs in that they don't require a separate download. This is advantageous in scenarios where sub-downloads are blocked or unavailable.
The Internet Explorer 8 data URI implementation attempts to balance security with functionality.
For more information, see the developer documentation for Data URI Support on MSDN.
return to top


Printing Improvements

Internet Explorer 8 includes several print enhancements. These form the basis for a full implementation of CSS 2.1 pagination recommendations, and provide authors with more control and functionality in the print medium. In particular, support has been added for the following printing constructs:
  • @page rule
  • left,right and first page selectors
  • "avoid", "left", and "right" values for page-break-after and page-break-before properties
  • page-break-inside property
  • widows property
  • orphans property
These improvements give developers greater control over how content is paginated across finite views. Developers can specify margin area, portions of content that must be kept together or split across pages, and much more. With this in mind, readability of printed web content can be greatly improved.
For more information, see CSS How-to: Optimize Pages for Printing Using CSS on MSDN.
return to top


Alternate style sheets

Internet Explorer 8 supports alternate style sheets. Specified by CSS 2 and HTML4, they allow page authors to define and name styles for a page (for example, to demo different design options to customers), to allow users to select a presentation style that suits their needs, or to display a document with or without annotations.
By using the Style commands (available from the Page or View menus), the user can select among the style sheets exposed by a website or disable style entirely.

Deprecating CSS expressions

Also known as dynamic properties, this non-standard CSS extension introduced in Internet Explorer 5 supports the definition of property values by using JavaScript or VBScript expressions. While powerful, this feature was never standardized, has a high performance cost and increases the browser's attack surface. Moreover, its main usage scenario has been to work around CSS bugs and limitations in Internet Explorer (for instance, to simulate max-width or pseudo-classes like : first-child). These workarounds will be redundant in Internet Explorer 8.
Starting with Internet Explorer 8, CSS expressions are no longer supported in standards mode.

Using the –ms prefix

Internet Explorer 8 introduces the -ms prefix for some non-CSS 2.1 properties. Prefixes are used in CSS for all vendor-specific properties. Previous versions have not required or accepted the prefix on Internet Explorer-only non-standard properties. Internet Explorer 8 is changing that. It is important to update your site if it uses any of these properties.
The following properties should be used with a prefix:
  • -ms-accelerator
  • -ms-background-position-x
  • -ms-background-position-y
  • -ms-behavior
  • -ms-block-progression
  • -ms-filter
  • -ms-ime-mode
  • -ms-layout-flow
  • -ms-layout-grid
  • -ms-layout-frid-char
  • -ms-layout-grid-line
  • -ms-layout-grid-mode
  • -ms-layout-grid-type
  • -ms-line-break
  • -ms-interpolation-mode
  • -ms-overflow-x
  • -ms-overflow-y
  • -ms-scrollbar-3dlight-color
  • -ms-scrollbar-arrow-color
  • -ms-scrollbar-base-color
  • -ms-scrollbar-dark-shadow-color
  • -ms-scrollbar-face-color
  • -ms-scrollbar-highlight-color
  • -ms-scrollbar-shadow-color
  • -ms-scrollbar-track-color
  • -ms-text-align-last
  • -ms-text-autospace
  • -ms-text-justify
  • -ms-text-kashida-space
  • -ms-text-overflow
  • -ms-text-underline-position
  • -ms-word-break
  • -ms-word-wrap
  • -ms-writing-mode
  • -ms-zoom
The following CSS3 properties should be used without a prefix:
  • box-sizing
  • rubyAlign
  • rubyOverhang
  • rubyPosition
return to top


Using filters

Due to its proprietary non-standard syntax, Microsoft strongly recommends that new filter declarations use the quoted -ms-filter property syntax, which requires the filter to be quoted. For instance, instead of the following:
filter:progid:DXImageTransform.Microsoft.Alpha(Opacity=80,FinishOpacity=70,Style=2);
Use:
-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80,FinishOpacity=70,Style=2)";
Note that -ms-filter property values must be quoted. Internet Explorer 8 will process existing unquoted filterdeclarations such as the one in the example above. However, the property will be applied if and only if its syntax is valid (all parentheses are present). If not, standard CSS 2.1 error recovery rules will apply and the property will no longer apply to your document. This may result in different rendering than Internet Explorer 7.

Encoding Detection

Prior to Internet Explorer 8, Internet Explorer defaulted to the code page of the referring document to decode a style sheet. Internet Explorer 8 now complies with the CSS 2.1 style sheet representation priorities defined by the standard. You now have the ability to control character set decoding by using the charset attribute of the link element or thecharset parameter of the HTTP Content-Type header. This level of control may be especially relevant for those style sheets that use generated content.

CSS Compatibility

One of the most important goals of Internet Explorer 8 is to be the most standards-compliant version of the browser ever. Please see CSS Compatibility and Internet Explorer for details about CSS compliance in recent versions of Internet Explorer, including support in Internet Explorer 8.
return to top


Accessibility Features

WC3's ARIA Support

The W3C defines ARIA (Accessible Rich Internet Applications) as syntax for enabling people with disabilities to access dynamic web content and custom UIs. Internet Explorer 8 uses ARIA role, state, and property information to communicate with assistive technologies. Instead of building separate simplified webpages for accessibility, use ARIA to mark up your rich web applications with roles, states, and properties. For example, to match the behavior created through a script, you can define a div element as a button, checkbox, or another ARIA role.
To learn more about ARIA and how to use it in your web content, use the following W3C ARIA working drafts:

UI Automation Support

User Interface Automation (UIA) is the Accessibility and Software Test Automation API. It was introduced in Windows Vista and .NET Framework 3.0, and is supported in Windows XP and later. Through UIA, Internet Explorer 8 relays to Assistive Technologies the ARIA markup information that supersedes the MSAA (Microsoft Active Accessibility) information set. For example, the minimum and maximum values of a custom webpage slider control are marked up using ARIA.
Because MSAA does not implement the concept of a slider, Assistive Technologies cannot get the information they need through MSAA. However, when communicating with Internet Explorer 8 through UIA, Assistive Technologies can access the behavior of the control and its values.
The following webpages provide information on the background, implementation, and use of UIA:
See Mapping ARIA Roles, States, and Properties to UI Automation for more information.
For more Accessibility features please check out Caret Browsing and Zoom.

Better AJAX Development

Improving developer productivity was one of the primary goals for Internet Explorer 8. The Internet Explorer team set out to achieve this goal in part by providing cross-browser interoperability, compliance with standards, and additional powerful APIs.
Internet Explorer 8 offers a simple and powerful programming model for AJAX development, encompassing interaction between browsers, webpages, and servers. As a result, you will find it easier to build webpages that provide improved user experience, greater functionality, and better performance. These APIs are based on web standards as defined in the W3C HTML 5 Working Group and the W3C Web Applications Working Group.
The following AJAX improvements bridge the browser-webpage gap to help you create a better user experience:
  • AJAX navigations enable users to navigate back and forth without leaving the AJAX application (webpage), and can be used to save the state of the AJAX application in the Address bar. This allows websites to trigger an update to browser components, such as the Address bar, by setting the value of window.location.hash, which raises an onhashchange event to alert components in the webpage to alter their state, as well as creating an entry in the travel log.
  • DOM storage is a simple-to-use method for storing and retrieving strings of key-value pairs. Data can be stored per tab instance of a session or stored on the local machine. This allows pages to cache text on the machine, reducing the effect of network latencies by providing faster access to pre-cached data. Several innovative uses are possible, such as in combination with the new network connectivity event, to allow a page to cache data if it detects that the computer is offline. Data URIs (which are text strings) can also be easily cached on the local machine.
  • Connectivity events allow websites to check whether a user is connected to the network through thewindow.navigator.onLine property, and to get notified of connectivity changes by way of the ononline andonoffline events.
  • Six connections per host for broadband scenarios instead of two, and a scriptable property, improve performance by allowing parallelization of downloads in Internet Explorer 8. This also increases functionality by ensuring that a request is not blocked to a host if two connections already exist. Websites can optimize downloads based on the window.maxConnectionsPerServer property.
  • XMLHttpRequest enhancements include a timeout property that can be set to cancel the request if necessary, allowing developers to better manage long-running synchronous and asynchronous requests.
Cross-domain communication is an integral part of AJAX development and mashup web applications. To help you build cross-domain communications that are safe and easy to implement, Internet Explorer 8 includes these three features:
  • With cross-domain request (XDR)developers can create cross-site data aggregation scenarios. Similar to theXMLHttpRequest object but with a simpler programming model, the XDomainRequest object is the easiest way to make anonymous requests to third-party sites that support XDR and opt into making their data available across domains. Because the XDomainRequest object ensures that the server and client explicitly opt-in, data aggregation for public sites (such as blogs) is simple, secure, and fast. As announced, XDR integrates with the Access Control framework from the W3C Web Applications Working group for cross-domain data that is "public"—that is, not user-specific.
  • Cross-document messaging (XDM) APIs allow easy, secure, and standardized communication through IFramesbetween documents from different domains with one simple call to the postMessage method.
  • Cross-domain security is further enhanced with an HTML sanitizer called toStaticHTML, which filters potentially harmful HTML content. Additionally, Internet Explorer 8 fully supports the ECMAScript 3.1's JSON parser. Developers can use the native JSON.parse and JSON.stringify APIs to safely translate between JavaScript objects and JSON data. By removing potentially harmful content, these parsing features go a long way toward securing the end user. Both toStaticHTML and JSON can be used with XDM, XDR and XHR, among other features in Internet Explorer 8.
For code samples and more information on these features, please refer to the AJAX pages in the Internet Explorer 8 SDKMSDN also contains documents for the APIs listed above.
return to top

DOM Improvements

Internet Explorer 8 has resolved many of the Document Object Model (DOM) inconsistencies found in previous versions of Internet Explorer with its new standards mode rendering engine. Developers who choose to opt out of this rendering mode can use IE7 compatibility mode for interoperability with legacy content by adding the  tag in the document's  element (or send the equivalent HTTP header on the server).
Internet Explorer 8 makes significant progress toward compliance and interoperability with W3C DOM standards. To improve JavaScript programming interoperability with the DOM standards, Internet Explorer 8 includes many fixes for standards-compliance issues in the implementation of the DOM L1 & 2 Core specification, as well as the DOM L2 HTML specification.
A few examples of common bugs that have been fixed in the Internet Explorer 8 DOM include the following:
  • Interoperable handling of HTML 4 elements: POBJECTQ, LABEL (supports intrinsic labels)
  • Interoperable object-as-image support
  • Unified implementation of HTML markup attribute handling APIs (getAttribute, getAttributeNode, etc.) to handle content attribute names: class, style, event handlers, etc.
  • Title attribute for tooltips only
  • Full checkbox and radio button support (name attribute fully supported in dynamic scenarios)
  • Positioning APIs no longer include the 2px border
See HTML Enhancements in Internet Explorer 8 for more information.
return to top

Native JSON Support

JavaScript Object Notation (JSON) is a simple and lightweight data-interchange format based on a subset of the object literal notation of the JavaScript language. The JScript engine shipped with Internet Explorer 8 implements theECMAScript 3.1 JSON proposal for native JSON-handling functions (which uses Douglas Crockford's json2.js API).
Native support for JSON is achieved by introducing a global JSON object with two built-in methods— stringify andparse. The new global built-in JSON object is defined in the JScript engine and is created during the engine initialization phase.
The global JSON object is similar to any other intrinsic global object in the JScript engine like Math, Date, and so on, and can be modified or overridden by the developer. If a user overrides the JSON object with a self-defined JSONobject, the user-defined object takes precedence over the built-in JSON object. In such a scenario, the user needs to implement the stringify and parse methods on the self-defined JSON object because the built-in methods are no longer be accessible to the user-defined JSON object.
The JSON.stringify method serializes a JScript value and returns a representative JSON text string, while theJSON.parse method de-serializes a JSON text string and safely revives it into a JScript object.
Because it is a native implementation and one which removes the dependency on the JScript eval method to "revive" JSON strings back into JScript objects, this implementation is both fast (for both serialization and deserialization of data) and secure compared to equivalent framework implementations.

Impact on existing websites

To maintain backward compatibility, this feature is only available when a site chooses to use the latest version of JScript features by using the “Internet Explorer 8 Standards” layout (document) mode. This feature might affect the behavior of webpages that depend on a global variable JSON or use json2.js. Though the global JSON object can be overridden, when a page chooses to use the “Internet Explorer 8 Standards” layout (document) mode it is not an undefined object anymore. With JSON now being instantiated as a global name by the JScript engine, checks like if(!this.JSON) would now evaluate to false and would need to be changed appropriately in the user code.
The webpages that use json2.js are unlikely to be affected. With very few exceptions, all these pages will continue to work, and likely work faster. These exceptions are due to the differences that exist between the Internet Explorer native JSON implementation and json2.js. For example, during serialization the native JSON implementation detects cycles and does not go in infinite recursion like json.js. You can find more about these exceptions at the JScript Blogs.
For more information, refer to the JSON Documentation and see Versioning and JScript Engine’s Version Support.
return to top


Mutable DOM Prototypes

Web applications have come a long way since the static webpage. Today, web developers need improved programming functionality, flexibility, and features to enable them to build the next generation of web applications. The Internet Explorer web platform provides many of the features and functionality necessary to build those applications. Where the web platform's built-in support ends, JavaScript—the principal scripting language used on the web—is often used to code innovative new features that supplement the web platform, cater to website-specific scenarios, normalize differences between browsers, and so on.
To provide web developers with the programming tools necessary to build new JavaScript scenarios that innovate, extend, and build upon the web platform, Internet Explorer 8 offers a collection of features that extend some of JavaScript's advanced functionality into the Document Object Model (DOM).


DOM Prototype support

Internet Explorer 8 extends the semantic capability of JavaScript prototypes into the Document Object Model (DOM). When web developers wish to interact with a webpage through JavaScript, they must use and interact with DOM objects, which are not part of the core JavaScript language. In previous versions of Internet Explorer, the DOM only provided object "instances" to the JavaScript programmer. For example, the DOM createElement property creates and returns an element instance, as in the following:
var div = document.createElement('DIV'); // Returns a new instance of a DIV element
This div instance is “derived” from a prototype that defines all of the properties that are available to that instance. Prior to Internet Explorer 8, the JavaScript constructor and prototype objects for div instances (and all other instances), were not available to the web developer. Internet Explorer 8 (when running in IE8 standards mode) reveals the constructor and prototype objects to JavaScript. In addition to allowing the customization of DOM object instances by way of their prototypes, DOM prototypes also help to clarify the internal representation of the DOM and its unique hierarchy in Internet Explorer, compared to other browsers.
For more information, see DOM Prototypes Part I: Introduction. For the complete list of DOM prototypes with their properties and methods, see the Prototypes reference page

Getter/setter support

An accessor (getter/setter property) is a new type of JavaScript property available in Internet Explorer 8. By using accessor properties, web developers can create or customize dynamic data-like properties that execute JavaScript code when their values are accessed or modified. The DOM prototype hierarchy defines all of its properties as built-in accessors. Web developers can also customize DOM built-in accessors to fine-tune the default behavior of the DOM.
Internet Explorer 8 is the first browser to implement support for the ECMAScript 3.1 standard syntax for creating accessor properties (Object.defineProperty).
return to top


Selectors API

Selectors are a query language for searching and "selecting" tags (elements) within a webpage. They are most commonly seen in CSS to "select" a group of elements to which certain properties will be applied:
Selector
{
   property: value;
   property2: value;
}
In Internet Explorer 7, there is no way of "executing" the selector independently of CSS. The Internet Explorer 8 implementation of the Selectors API is based on the specification of the W3C Web Applications Working Group:http://www.w3.org/TR/selectors-api/
See Selecting Objects with JavaScript for more information.

return to top

Improved Namespace Support

Internet Explorer 8 offers web developers the opportunity to write standards-compliant HTML-based webpages that support features (such as SVG, XUL, and MathML) in namespaces, provided that the client has installed appropriate handlers for those namespaces via binary behaviors. (A binary behavior is a type of ActiveX control.)
Internet Explorer 5 through Internet Explorer 7 provides limited element namespace support. (This support keeps the parser from treating namespaced elements as native HTML elements.) By using element namespaces, web developers can apply behaviors to those elements through special HTML markup (called HTML Components or HTCs), and COM developers can apply binary behaviors. Only elements in a namespace can have binary behaviors applied to them.
Internet Explorer 8 improves its namespace support by supporting default namespace declarations on elements not included in the set of known HTML tag names.


  
   Hello
  

 
In the previous example, both the "newtag" and "folder" elements will be treated as namespaced elements in Internet Explorer 8.
See Namespace Support in Internet Explorer for more information.

return to top


Versioning

Versioning and Internet Explorer modes

Versioning and Internet Explorer rendering modes enable Internet Explorer 8 to remain compatible with today's web content. These modes also provide a mechanism for introducing new features and stricter standards of compliance.
Internet Explorer 8 has three different layout modes:
  • Quirks: backwards compatibility with Internet Explorer 5 rendering behavior
  • Internet Explorer 7 Standards: backwards compatibility with Internet Explorer 7 JavaScript and layout behavior
  • Internet Explorer 8 Standards: latest features, including the CSS 2.1-compliant layout engine and DOM/HTML breaking changes
By default, Internet Explorer will attempt to display content by using its most standards-compliant mode: Internet Explorer 8 Standards mode. To allow the existing site content to remain compatible with Internet Explorer 8, site operators may designate the correct layout mode for Internet Explorer 8 clients by using a new compatibility mode switch.
For more information, see Defining Document Compatibility.

Versioning and Cross-Document Interaction

Internet Explorer 8 introduces the Internet Explorer 8 Standards mode by default; this allows web designers to use the latest rendering features available in the browser. In addition to layout changes, Internet Explorer 8 Standards mode will also affect the behavior of scripted APIs (DOM). To opt out of Internet Explorer 8 Standards mode, the meta tag may be used to obtain Internet Explorer 7 Compatibility mode:
Internet Explorer 8 introduces the Internet Explorer 8 Standards mode by default; this allows web designers to use the latest rendering features available in the browser. In addition to layout changes, Internet Explorer 8 Standards mode will also affect the behavior of scripted APIs (DOM). To opt out of Internet Explorer 8 Standards mode, the meta tag may be used to initiate Internet Explorer 7 Compatibility mode:
Versioning of the DOM APIs introduces additional complexity for web developers who interact through script with framesets and inline frames, HTC files (element behaviors), and various HTML dialogs that are in different modes. For example, a frame that is in Internet Explorer 8 Standards mode may interact with another frame that is in Internet Explorer 7 Compatibility mode. Script authors must understand how versioning will affect DOM APIs that have different behaviors when invoked across document boundaries. The following scenarios illustrate these behaviors:
  • A single webpage may host one or more IFrames that contain documents of different modes. For example, a webpage in Internet Explorer 7 Compatibility mode (such as a portal) may host newer Internet Explorer 8 Standards mode content.
  • A webpage may create a new window or dialog (for example, through window.open) that loads content from a document of a different mode. The webpage then proceeds to call DOM APIs on that new window.
Other scenarios, such as frameworks and mashups injected through document.write or

关注者