2023年12月19日发(作者:)

IE6-IE11兼容性问题列表及解决办法

2015/3/2 Bob Liu

名目

概述 3

第一章:HTML 4

第一节:IE7-IE8更新 4

1. 如果缺少终止标记的 P 元素后跟 TABLE、FORM、NOFRAMES

或 NOSCRIPT 元素,会自动添加终止标记。 4

2. 支持格式正确的有效标记,不再支持格式错误的 HTML。 6

3. Button标签的默认type类型从button改为submit。 7

4. 不再支持 COL 及 COLGROUP 元素的部分属性及为其设定的 CSS 特性. 8

第二节: IE8-IE9更新 9

1. 表对象模式现在更加符合其他扫瞄器。 9

2. 文本布局使用自然度量而不是图形设备接口 (GDI) 度量。 12

第二章:CSS 15

第一节:IE6-IE7更新 15

1. 方框模型溢出内容现与方框相交,不再让方框自动增长适应内容。 15

2. 不再支持某些 CSS 选择器(如 *HTML、_underscore 和 /**/ 注释)。 17

3. 已解决SELECT 元素不能被div覆盖的咨询题。

4. CSS样式区分大小写。 22

中的height, width结尾需要输入单位,如px 23

第二节:IE7-IE8更新 23

1. 不再支持 CSS 表达式,改为支持增强的 CSS 或 DHTML 逻辑。 23

第三节:IE8-IE9更新 25

1. 泰语和东亚语文本和字体大小的显示可能小于其他字样。 25

21

2. 某些行为连接方法在 XML 模式中不可用。 26

第四节:IE9-IE10更新 28

1. 不再支持 CSS behavior,完全废弃htc表达式。28

第三章:Javascript and DOM 29

第一节:IE6-IE7更新 29

1. 不再承诺用于绕过 提示的 技巧。 29

2. 从脚本创建的模式或无模式对话框看起来看起来略微变大。 30

第二节:IE7-IE8更新 31

1. 支持“class”语法,不再支持“className”属性语法。 31

2. 属性集合不再包含 Internet Explorer 可识不的所有可能属性。

2

3. 属性排序已更换,阻碍了属性集、innerHTML 和 outerHTML。 33

5. currentStyle 对象的Unset属性现在返回其初始值。 35

6. style 对象的 Unset 属性值现在返回空字符串。 37

第三节:IE8-IE9更新 38

1. createElement 方法中不承诺使用尖括号<> 。 38

2. IE9 标准模式不支持 属性。 39

3. 不再支持使用不带“.call”或“.bind”的函数指针调用方法。 41

4. 不再连接内容属性和 DOM expando。

5. JavaScript 属性列举在IE9 中不同。 45

6. 数学精确度在IE9 中不同。 47

7. 间接“eval”函数调用的行为方式不同。 49

8. IE9 处理含大型索引的数组项目的方式不一样。 51

9. 重叠元素会被复制。 52

10. DOM中会保留空格。 54

11. 部分DOM 事件已过时。 55

第四节:IE10-IE11更新 57

43

3

1. 已删除attachEvent,改用addEventListener。 57

2. 已删除ript,改用eval。 57

3. 已删除ll,改用Left、Top。 57

5. 已删除ze、ze,使用 XMLHttpRequest 可提取源。

oad。 57

7. 已删除ion,改用ection。 57

8. 已删除StyleSheet,改用Element("style")。 57

9. 已删除heet,改用。 57

10. 已删除Popup,改用 div 或 iframe(zIndex 值专门高)。 57

第四章:其他更新 58

第一节:IE7-IE8更新 58

1. 文件上载控件仅向服务器提交文件路径,而不提供完整路径。

8

第二节:IE8-IE9更新 59

1. 预设使用者代理(UA) 字串已变更. 59

57

6. 已删除ystatechange 和 tate,改用5

概述

本文档内容涵盖:IE6升级到IE11过程中Javascript, DOM, HTML, CSS等方面的变化和调整。

参考依据MSDN:

Appendix 1: Internet Explorer 6 to Internet Explorer 9 Browser Changes

附录 1:从 Internet Explorer 6 到 Internet Explorer 9 的扫瞄器更换

Internet Explorer 9 Compatibility Cookbook

邊做邊學 IE9 相容性操作手冊

Internet Explorer 11 开发人员指南

第一章:HTML

第一节:IE7-IE8更新

如果缺少终止标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或

NOSCRIPT 元素,会自动添加终止标记。

MSDN原文:Unclosed P elements are now automatically closed when followed by TABLE, FORM, NOFRAMES, or NOSCRIPT elements.

所属分类

HTML

版本更新

IE7-IE8

具体描述及示例:

如果缺少终止标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或

NOSCRIPT 元素,会自动添加终止标记,即:TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素不能再嵌套在段落元素P中了。

考虑如下代码:

Simple P Element Closing Example

This is the first paragraph

This is another paragraph.

This is a table cell.

This is a third paragraph.

在那个例子中,第二个P元素没有关闭。在IE6, IE7下,Table元素显示为第二个p元素的子元素。第二个p元素是窗口的左边界缩进30像素。因为该表是一个P元素的子元素,它也从窗口的左边界缩进。IE7下Html结构图如下:

然而,与IE8时,在默认模式下,TABLE元素对齐到左边缘。因为IE8会自动关闭显示表元素之前闭合的P元素,TABLE元素的子元素。IE8下Html结构图如下:

解决方案及正确写法:

请注意此特性, 在代码中规避风险。

支持格式正确的有效标记,不再支持格式错误的 HTML。

MSDN原文:Malformed HTML is no longer supported, in favor of

well-formed, valid markup.

所属分类

HTML

版本更新

IE7-IE8

具体描述及示例:

支持格式正确的有效标记,不再支持格式错误的 HTML

Malformed HTML is no longer supported, in favor of well-formed, valid markup.

Parser error correction for malformed HTML has changed in IE8 Standards Mode. Pages depending on the way IE7 performs error correction

may encounter issues as a result.

  • 1.1

    • 1.1.1
    • 1.1.2

在IE8下能够看到如下成效图:

解决方案及正确写法:

HTML标记写法要严谨。

Ensure your markup is well-formed and valid.

  • 1.1

    • 1.1.1
    • 1.1.2

修改后,IE8下成效图如下:

Button标签的默认type类型从button改为submit。

所属分类

HTML

版本更新

IE7-IE8

具体描述及示例:

如果不为Button设置type属性,旧版IE会将其自动设为button类型,而从IE8开始,为了遵守W3C标准,改变了原先的默认做法,现在默认此button为submit,而非button类型。

解决方案及正确写法:

需要为按钮设置type类型。

不再支持 COL 及 COLGROUP 元素的部分属性及为其设定的 CSS

特性.

IE6 IE7 IE8(Q) 对 COL 和 COLGROUP 元素的属性及部分 CSS 特性支持较好,而IE8(S), IE9不再支持 COL 及 COLGROUP 元素的部分属性及为其设定的 CSS 特性。

不支持的属性截图如下:

例如:colgroup和col的使用如下:

日期 分数

但IE9差不多不支持页面中的align和style属性了,但还支持width属性。

因此,我们只好舍弃在colgroup, col中设置样式,转而直截了当在td,

th中设置。

至于仍旧支持的width属性,建议也同样修改,以保持统一的风格, 到Html5中,将不再支持width属性了.

HTML 5 标签

第二节: IE8-IE9更新

表对象模式现在更加符合其他扫瞄器。

MSDN原文:Table Object Model Is Now More Consistent with Other Browsers.

所属分类

HTML

版本更新

IE8-IE9

具体描述及示例:

为了提升IE和其他扫瞄器之间的一致性,IE9的标准模式的表Table发生了以下变化:

•额外的THead和TFoot元素可不能显现在s集合中。那个地点所指的是s属性,并不是在tBody里面放thead或者tfoot。如果有余外的thead或者tfoot,IE9模式下可不能把它们计入在内,而在IE8模式下会把余外的thead或tfoot单独计入到一个tBody。

•Table的行集合有着不同的顺序。不管他们在文档内的顺序是什么,第一是THead内容, 其次是TBody内容,最后才是TFoot内容。

•调用rows统计将返回一个表内的所有层次的TR行数,包括直属TR行。也确实是指把table里面的所有TR对象都计入在rows列表里面,而不论它是在根节点依旧thead/tfoot/tbody里面

To improve consistency between Windows Internet Explorer and other browsers, the IE9 Standards mode includes the following changes to the

table object model:

•Extra thead and tfoot elements do not appear in the tBodies collection.

•The rows collection has a different ordering. First, it includes any rows in the thead element, then all remaining rows that are not in the tfoot element, and then any rows in the tfoot element, regardless of their order in the document.

•A call for rows returns all rows at all depths within the table, including direct row children of the table.

如果不考虑这些变化在您的应用程序,应用程序可能会遇到次要的脚本错误,页面始终保持在加载中状态,或创建非预期内容等错误。

If you do not consider these changes in your application, the application might encounter script errors that are minor, that keep pages from loading, or that create content that is not intended.

考虑如下代码:

Table Test

Row1
Row2
Foot
Head1
Head2

点击Click Me按钮,IE8将弹出提示,显示有三个tBody, 实际上只有一个tbody,然而IE8将余外的一个thead和一个tfoot都各自单独计入一个tBody里了。而IE9则可不能有那个咨询题,只显示有一个tBody。

注释:Table包含 thead、tfoot 以及 tbody 子元素, thead元素用于定义表格的表头,tfoot用于定义表格的表尾,tbody为表格中的主体内容。thead 元素应该与 tbody和 tfoot元素结合起来使用。

解决方案及正确写法:

注意此特性,规避风险。

有关资源:

文本布局使用自然度量而不是图形设备接口 (GDI) 度量。

MSDN原文:Text Layout Uses Natural Metrics.

所属分类

HTML

版本更新

IE8-IE9

具体描述及示例:

关于IE9 标准模式中的文字版面配置, IE9 使用自然度量法,而非旧版IE 扫瞄器使用的图形装置介面(GDI) 度量法。GDI 度量法会将文字与像素界限对齐,而自然度量法则会使用内部像素的间距来出现更准确且更容易阅读的文字。

IE 的其他文件模式则连续使用GDI 度量法。

针对旧版文件模式所写的页面版面配置在IE9 中可能无法正确显示。

最常見的错误是未预期的文字換行,這可能会遮盖位于换行文字下方的元素。当文字方块沒有余外的水平空间或是当文字方块的大小与頁面上的其他元素(例如图形) 相连时,专门可能会发生此错误。

Other document modes for Windows Internet Explorer continue to use GDI metrics.

Page layouts that are written for earlier document modes might display incorrectly in Internet Explorer 9. The most common error is unexpected text wrapping, which can cover elements that are below the wrapped text. This error is most likely when a text box does not include extra horizontal space or when the size of the text box is connected to another element on the page, such as a graphic.

解决方案及正确写法:

不要假设特定字型的大小在不同扫瞄器间或是在相同扫瞄器内都会依相容的方式出现,因为使用者有可能会缩放扫瞄器的字体 (例如,125%)。

利用下列设计准则,可确定您的网页显示文字版面配置的方式一致:

1.将Textbox的大小设定为特定的像素数。

2.在Textbox中留些余量空间,幸免空间过紧。

3.使用非Static大小的Textbox。

4.在与其他页面元素相连接处包含额外空间。

5.如果您承诺用户改变页面字体的大小,就要请您确认页面能够适应文字换行。

6.如果您发觉文字换行的咨询题,请您调整页面,确保页面能够恰当地出现文字。

幸免对文字版面配置采纳下列设计:

1.希望字型大小在不同扫瞄器间以相同的方式出现。

2.使用Static大小的textbox。

关于Static大小的textbox, 含义如下例:

那个地点就指定了text box的size,非静态non-statically意思是讲我们不要去指定size。如果一定要指定,尽量用如上的px作为单位。

Do not assume that the size of a particular font renders identically across browsers or within the same browser because users can choose a larger font display (for example, 125%).

Do

Use the following design guidelines to make sure that your webpages display text layout consistently:

•Set a text box's size to a specific number of pixels.

•Include extra space in your text boxes and avoid tight spaces.

•Use non-statically sized text boxes.

•Include extra space in bounding areas that depend on other page elements.

•Make sure your page can accommodate text wrapping if you permit users to change the page font size.

•If you designed a webpage for a previous mode and you do not want to update it to use natural metrics, set the page to display in that mode even when users view it in Internet Explorer 9.

Do not

Avoid the following designs for text layout:

•Depend on font sizes to render the same way across browsers.

•Use static-sized text boxes.

有关资源:

第二章:CSS

第一节:IE6-IE7更新

方框模型溢出内容现与方框相交,不再让方框自动增长适应内容。

MSDN原文:Box model overflow content now intersects box, no longer auto-grows box div to fit content.

所属分类

CSS

版本更新

IE6-IE7

具体描述及示例:

在IE7中,为了适应CSS2.1 box model,微软修改了溢出的行为。溢出是用来描述当一个块元素的内容溢出它的区域时,这些内容是否被剪切掉的一种方法。默认情形下,内容不被剪切,也确实是,它有可能出现在区域以外。过去的IE不支持那个行为。内容总是需要适合区域的大小。想

象一个宽和高差不多上100px的区域,如果内容小于100px,那么没有咨询题。如果内容超过了尺寸,我们需要自动增长区域大小来适合内容。

In IE7, we changed the behavior of overflow to align with the CSS2.1 box model. Overflow is describes as a method to specify whether content of a block-level element is clipped when it overflows the box. The default is visible. This value (visible) indicates that content is not clipped,

i.e. it may be rendered outside the box. IE in the past did not support this behavior. Content always had to fit within a box dimensions. Imagine

a box with width and height of 100px. If the content is smaller than 100px then IE would follow the specifications. If the content exceeded the size we would auto-grow the box to fit the content. To demonstrate this behavior, take a look at the following code sample.

请看下面的代码示例。

some text long enough to make it interesting.

- anonymous

下图显示了在IE6和IE7中此段代码的不同成效,(上图为IE6,下图为IE7):

从图中能够看出,

内容超出了div的边界,在IE7下,div不再自动增长来装下
,而是让
伸出div的边界。

As you can see, we now honor the height and width settings of a box. In this example, the

content now renders outside of the boundaries of the parent
(box with red borders).

解决方案及正确写法:

请检查有关的页面设计,如果往常依靠自动增长这一特性,现在就需要修改代码,来幸免页面布局显示错误的风险。

If your layout relied on us "growing" the box (if your content did not fit the dimensions you gave it) then this can lead to breaks. You can

easily discover breaks related to overflow by observing content suddenly

overlapping other content.

有关资源:

不再支持某些 CSS 选择器(如 *HTML、_underscore 和 /**/ 注释)。

MSDN原文:Certain CSS filters (for example, *HTML, _underscore,

and /**/ comment) are no longer supported.)

所属分类

CSS

版本更新

IE6-IE7

具体描述及示例:

尽管CSS标准差不多存在,然而并不保证所有的扫瞄器用同样的方式出现页面。这些标准可能含有未经定义的部分,并不是所有的组件等会被所有的扫瞄器去执行,同时已知的执行也可能存在咨询题。CSS标准并不提供一个方法去指定一个特定的扫瞄器版本,因此网络开发者社区开发了CSS filter(也被称作”CSS hacks”)。这些filter利用扫瞄器的咨询题或者未执行的特性来隐藏针对专门扫瞄器的CSS样式规则。当我们修复了这些咨询题同时改进了CSS支持后,一些CSS filter将不再可用。

如果你使用这些filters,你应该了解它们的成效。那个能够关心你做出针对以后版本的Internet Explorer和其它扫瞄器的更有效的同时适应改进后的CSS的设计。

在IE7中,我们修改了许多潜在解析错误,这些错误有可能会阻止下面的filter在往常的IE版本中正常工作。如果你的页面中包含这些filter,请去除或者更换它们。

Even though standards like CSS are available it is not a guarantee that all browsers render the same way. The standard might have undefined

parts, not all components are equally implemented by all browser vendors, and existing implementations might have bugs. The CSS standard does not provide a way to target specific browser versions and as a result the

Web developer community has developed CSS filters (also called "CSS ha

cks"). These filters take advantage of browser bugs or unimplemented features to hide CSS style rules from specific browsers. As we fix these bugs and improve CSS support, some CSS filters will stop working.

If you use such filters, you should understand their effects. In this long run, this will help you create designs that more effectively adapt to improved CSS support in later versions of Internet Explorer and other browsers.

In IE7, we fixed many underlying parser bugs that prevented the following filters from working in earlier versions of IE. If your page contains these filters, please remove or replace them (at the end of this article

we will offer other means of targeting reliable IE versions).

具体举例如下:

*HTML filter

那个CSS filter基于一个解析错误。它被用于显示排除内容。这些内容将被Internet Explorer7和以后的版本忽略。

/* The following rules used to apply only to

IE but now get ignored by IE7 and higher */

* html{

}

* html body{

}

* html .foo{

}

下划线filter

那个CSS filter基于一个解析错误。它被用来显示被排除的属性。那个内容现在被Internet Explorer以及之后的版本认为是一个自定义属性。自定义属性意味着它仍旧能够使用,然而并不默认就拥有一个值。

/* The following rule used to apply min-height

to browser who understand this property and

height to IE. In IE7, _height will be treated

as a custom property (no height will be applied) */

.myclass {

min-height: 300px;

_height: 300px;

...

}

/**/注释filter

那个CSS filter基于一个解析错误。它被用来在strict模式下隐藏属性(那个filter在quirk模式下不起作用)。在Internet Explorer7中,那个属性能够被解析和使用。

/* The following rule used to hide the height

property to Internet Explorer. In IE7, the

value will be applied */

.myclass {

height/**/: 300px;

...

}

解决方案及正确写法:

如果使用了上述CSS选择器,停用即可。

有关资源:

已解决SELECT 元素不能被div覆盖的咨询题。

MSDN原文:Applications that relied on SELECT element to get an

HWND to use with Microsoft Win32 APIs may break because SELECT element is now a windowless control.

所属分类

CSS

版本更新

IE6-IE7

具体描述及示例:

Select元素现在已改为无窗口控件, 这项改变使z-order 和 zoom缩放能正常工作了,也就讲, 这次完全解决了IE6中Select不能被div覆盖的咨询题,除此之外,其他都和往常保持一致;

然而,如果有应用程序依靠从Select控件猎取窗口的HWND就必须修改为使用DOM了,因为Select元素现在是无窗口控件,也就得不到HWND了。

Select Element—The Select control is now a windowless control. This change enables z-order and zoom to work correctly. The HTML and Document Object Model (DOM) for Select remain the same, so Web developers and end users interact with Select as before; however, applications th

at relied on getting an HWND from Select to use with Microsoft Win32

APIs must be modified to use the DOM.

解决方案及正确写法:

注意此特性即可。

有关资源:

Select control: CSS style-able and not always on top

4. CSS样式区分大小写。

如下代码,在IE6下,CSS样式类名不分大小写,但从IE7开始,区分大小写了, IE8和IE9也区分大小写,也确实是讲,我们CSS样式类和使用它的地点,必须保持完全一致。

this is for div1

this is for div2

中的height, width结尾需要输入单位,如px

如下代码,在ie6下,能够读取到style中定义的height=30,但从ie7开始,就必须在height:30后面加上单位px了,否则,读取不出来height值。

this is for div2

第二节:IE7-IE8更新

不再支持 CSS 表达式,改为支持增强的 CSS 或 DHTML 逻辑。

MSDN原文:CSS expressions no longer supported, in favor of improved CSS support or DHTML logic.

所属分类

CSS

版本更新

IE7-IE8

具体描述及示例:

不再支持 CSS 表达式,改为支持增强的 CSS 或 DHTML 逻辑。

CSS expressions no longer supported, in favor of improved CSS support or DHTML logic.

Support for CSS Expressions has been removed in IE8 Standards Mode.

CSS 表达式的例子:

#main {

background-color: expression(

(new Date()).getHours()%2 ? "#000" : "#fff"

);

}

解决方案及正确写法:

停用CSS Expressions,重构代码.

Refactor to utilize either improved CSS support or DHTML logic.

/* Script */

if((new Date()).getHours()%2) {

oundColor = "#000";

} else {

oundColor = "#fff";

}

有关资源:

第三节:IE8-IE9更新

泰语和东亚语文本和字体大小的显示可能小于其他字样。

MSDN原文:Thai and East Asian Text and Font Sizing.

所属分类

CSS

版本更新

IE8-IE9

具体描述及示例:

泰文和东亚文字在IE9 看起来可能比在IE8 和旧版本中还要小。

在IE8 中,泰文和東亚文字可在下列情況下以大于指定大小的字型出现:

1.指定font size为9pt 或更小.

2.指定的font-family不支持泰文或東亚文字,例如Arial指定的字型系列不支持泰文或东亚文字。

因此,8pt Arial 的泰文段落会使用[Internet Options-Fonts] 中指定的后援字型来出现,而后者之后会配合Ariel 公制放大调整。因此,如果网页作者要求使用8pt 的字型大小,则实际尺寸会更大。

在IE9 中,则始终采纳指定的字型大小。因此,由于后援字型可不能再放大调整,文字可能看起来可能会比较小。

Thai and East Asian text may look smaller in IE9 than in IE8 and earlier releases. In IE8, Thai and East Asian text could be rendered at a larger font size than specified when:

•The specified font size was 9pt or smaller

•The specified font family did not support Thai or East Asian characters such as Arial

Thus, a Thai paragraph of 8pt Arial would be rendered using the fallback font specified in Internet Options-Fonts and the latter would then be scaled up to match Arial metrics. As a result, the real size is larger than it would have been if the web author had requested that font at 8pt.

In IE9, the specified font size is always respected. Thus, as the fallback font is no longer scaled up, text may appear smaller.

解决方案及正确写法:

请尽可能确定CSS font-family 属性的第一个值支持您的语言。

此咨询题还会阻碍到多语言界面的CSS字体设置。

有关资源:

某些行为连接方法在 XML 模式中不可用。

MSDN原文:Some Behavior-Connecting Methods Do Not Work in XML.

所属分类

CSS

版本更新

IE8-IE9

具体描述及示例:

用于连接行为的标记式表单在Windows IE9 模式中可运作,但在xml

模式中则无法运作。

The markup-based form for connecting behaviors works in Windows

Internet Explorer 9 modes, but it does not work in xml mode.

行为可在网页的最上层指定,如下面的程式码范例所示。

A behavior can be specified at the top of a webpage, as the following code example shows.

此咨询题只阻碍新内容。

This problem affects only new content.

解决方案及正确写法:

请不要使用HTML标记,而是通过CSS的behavior属性注册,如下例所示。

Instead of using HTML markup, use Cascading Style Sheets (CSS)-based registration through the behavior property, as the following code example shows.

您能够透过class属性以外的元素使用CSS注册。

You can use CSS-based registration through elements other than the

class attribute.

有关资源:

第四节:IE9-IE10更新

不再支持 CSS behavior,完全废弃htc表达式。

所属分类

CSS

版本更新

IE9-IE10

具体描述及示例:

htc文件将不再有效,全部被剔除。

解决方案及正确写法:

具体解决方案请参考:

有关资源:

Does IE10 standard mode still support HTML Component(htc)? If not, which tech will instead htc?

I don't think behaviors are supported in IE10

you will find a complete comparison of features support in different

IE versions and other browsers at the IE

Debugging your web apps using the Developer Tools>Script or Console tab, should give a listing of warning and error messages for unsupported features that have been ignored by the documentMode that you

for backward compatibility with IE10 you can add the IE9 x-ua meta

many of the htc behaviors have since been replaced by html5, css3

or js shims.. I would imagine there is no further need to support them in html5/css3 compliant browsers.

the Compatibility "Display intranet sites in compatibility view" allows legacy intranet documents to still use legacy features until such time as the corporate developers update their intranet sites to 'Standards' compliant markup and later versions of the css specs. If managing

intranet sites that use htc behaviors, your migration strategy should be to

replace them with equivalent css3 or js shims (jQuery, dojo, but not Extjs).

these are public peer to we do not work for nor represent MS.

第三章:Javascript and DOM

第一节:IE6-IE7更新

不再承诺用于绕过 提示的 技巧。

MSDN原文: trick used to bypass the prompt is no longer allowed.

所属分类

Javascript and DOM

版本更新

IE6-IE7更新

具体描述及示例:

不再承诺用于绕过 提示的 技巧。

and --Internet Explorer 7 no longer allows the trick to bypass the prompt. Browser windows cannot close themselves unless the windows were created in script.

This security enhancement no longer allows browsing to a random site

when the main browser window closes unexpectedly.

解决方案及正确写法:

在IE6中,当我们用这种方法:("")

总是会提示:你查看的网页试图关闭的提示。在IE6下, 能够用以下方法,去掉提示,直截了当关闭窗体: ("")

opener只要设为任何值都能够,可不能显现提示。

在IE7及以上版本中,此写法就不被承诺了。

注意此新特性即可。

有关资源:

从脚本创建的模式或无模式对话框看起来看起来略微变大。

MSDN原文:Modal or modeless dialogs created from script might seem slightly bigger.

所属分类

其他

版本更新

IE6-IE7更新

具体描述及示例:

从脚本创建的模式或无模式对话框看起来看起来略微变大。

Changes that affect modal or modeless dialogs created from script--Modal or modeless dialogs created from script in Internet Explorer 7 might seem to be slightly bigger than their Internet Explorer 6 counterparts. Th

is is caused by a change to the behavior of the dialogWidth and dialogHeight properties, which now set and retrieve dimensions of the content area of a dialog (from Internet Explorer 7 and later). It will no longer be necessary to calculate the area lost by elements of a dialog’s frame.

解决方案及正确写法:

需要目测,看是否需要调整。

有关资源:

Why Does IE Resize My Dialogs?

第二节:IE7-IE8更新

支持“class”语法,不再支持“className”属性语法。

MSDN原文:“className” attribute syntax no longer supported, in favor of “class” syntax.

所属分类

Javascript and DOM

版本更新

IE7-IE8

具体描述及示例:

在IE7中,必须使用属性名称为“ClassName”来设置和检索元素的类。在IE8中差不多被修改为符合标准,因此需要使用“class”来设置和检索元素的类。

In IE7, "className" had to be used as the attribute name to set and retrieve the class of an element. This has been fixed for standards-compliance in IE8 Standards Mode. Using the old approach will create an attribute named "className" that has no affect on the actual class assigned to an element.

return ribute("className");

解决方案及正确写法:

使用规范的名称,“class”,而不是为“ClassName”。

return ribute("class");

例子:

function GetClass()

{

}

使用getAttribute("className"),在IE8中会得到Null的错误提示。

使用getAttribute("class"),在IE8中会得到INPUT的正确值。

有关资源:

属性集合不再包含 Internet Explorer 可识不的所有可能属性。

MSDN原文:The attributes collection no longer contains all possible

attributes recognized by Internet Explorer.

所属分类

Javascript and DOM

版本更新

IE7-IE8

具体描述及示例:

属性集合不再包含 Internet Explorer 可识不的所有可能属性.

The attributes collection no longer contains all possible attributes recognized by Internet Explorer.

The attributes collection no longer contains all possible attributes recognized by IE, but only those that have been explicitly set. Scripts can fail if they depend on natively supported attributes always being present as they were in IE7.

例如:

var attr = utes["checked"];

// Potential script error in IE8

return ied;

解决方案及正确写法:

要先检查确认属性存在,而后再使用。

Do not assume an attribute will be in the attributes collection. Check for existence first.

正确写法:

var attr = utes["checked"];

if(attr) return ied;

else return false;

有关资源:

属性排序已更换,阻碍了属性集、innerHTML 和 outerHTML。

MSDN原文:Attribute ordering has changed, affecting attributes collection, innerHTML, and outerHTML.

所属分类

Javascript and DOM

版本更新

IE7-IE8

具体描述及示例:

属性排序已更换,阻碍了属性集、innerHTML 和 outerHTML。

Attribute ordering has changed, affecting attributes collection, innerHTML, and outerHTML.

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 = utes[1]; // May differ in IE8

解决方案及正确写法:

请用属性取id代替属性所在位置索引。

Reference attributes by name as opposed to their position within the

attributes collection.

attr = utes["id"];

有关资源:

所属分类

Javascript and DOM

版本更新

IE7-IE8

具体描述及示例:

解决方案及正确写法:

遵守区分大小写的特性即可。

有关资源:

currentStyle 对象的Unset属性现在返回其初始值。

MSDN原文:Unset properties on the currentStyle object now return their initial value. This is the root cause of issues with the menu control.

所属分类

CSS

版本更新

IE7-IE8

具体描述及示例:

现在,currentStyle 对象的Unset 属性会返回其初始值”auto”, 这是

菜单控件咨询题的全然缘故。

Unset properties on the currentStyle object now return their initial value. This is the root cause of issues with the menu control (example).

Initial CSS Property Values

Unset properties on the currentStyle object now return their initial value. Relying on the old initial values for CSS properties such as z-index can cause problems. This is the root cause of issues with the menu control.

var zIndex = ;

if(zIndex == 0) {

// custom code

}

注释1:currentStyle 对象,它用来返回元素上的样式表,然而 style

对象只返回通过 STYLE 标签属性应用到元素的内嵌样式。因此,通过 currentStyle 对象猎取的样式值可能与通过 style 对象猎取的样式值不同。例如,如果段落的 color 属性值通过链接或嵌入样式表设置为红色( red ),而不是内嵌的话,对象. 将返回正确的颜色,而对象 不能返回值。然而,如果用户指定了

,currentStyle 和 STYLE 对象都将返回值 red。

注释2:z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。

解决方案及正确写法:

例子:下面button不设置style属性(也就谈不上置width和zindex了),则和都返回默认值auto.

要做如下双重检查:

Perform a check for both the backwards compatible value and the standardized initial value.

var zIndex = ;

if(zIndex == 0 || zIndex == "auto") {

// custom code }

有关资源:

currentStyle 对象

style 对象的 Unset 属性值现在返回空字符串。

MSDN原文:Unset properties values on the style object now return empty string.

所属分类

CSS

版本更新

IE7-IE8

具体描述及示例:

style 对象的 Unset 属性值现在返回空字符串。

Unset properties values on the style object now return empty string.

Unspecified CSS Property Values

Unset properties on the style object now return the empty string for

improved compliance with the DOM Level 2 Style Specification. Expecting CSS properties such as z-index to have a value when they have not been explicitly set can lead to problems.

var zIndex = ;

if(zIndex === 0) {

// custom code

}

解决方案及正确写法:

要做如下双重检查:

Perform a check for both the backwards compatible value and the empty string.

var zIndex = ;

if(zIndex === 0 || zIndex === "") {

// custom code

}

有关资源:

第三节:IE8-IE9更新

createElement 方法中不承诺使用尖括号<> 。

MSDN原文:Angle Brackets Are Not Allowed in the createElement

Method.

所属分类

Javascript and DOM

版本更新

IE8-IE9

具体描述及示例:

IE9不能识不createElement方法内的角括弧(< >)。如果您在IE9 的页面中使用角括弧,会发生专门。

Windows IE 9 does not recognize angle brackets (< >) within the createElement method. If you use angle brackets in IE 9 webpages that are not set to previous Windows IE Standards document modes, an exception occurs. For example, the following code example will cause an exception in IE9 mode.

例如,下面的例子在IE9 模式中引发专门。

var el=Element("

");

解决方案及正确写法:

要顺应IE9 中的这项变更有两种方法:

使用setAttribute API 建立元素并分不新增属性,如下面的代码范例所示。

var elm = Element("div");

ribute("id","myDiv");

使用innerHTML API 在父元素内建立元素,如下面的代码范例所示。

var parent=Element("div");

TML="

";

var elm=hild;

或者,也能够将网页设定为IE9 往常的文件模式。

有关资源:

IE9 标准模式不支持 属性。

MSDN原文:IE9 Standards Mode Does Not Support the Property.

所属分类

Javascript and DOM

版本更新

IE8-IE9

具体描述及示例:

IE9 标准模式中不再支持 属性。

当建立argument objects时,在IE8 和Quirks 中的所有模式,以及IE9 的IE7 标准和IE8 标准模式,都会建立一个名为“caller” 的属性。此caller 属性会储存对呼叫它的函数的argument Object参照。

When argument objects are created, in all modes of IE8 and Quirks, IE7 Standards, and IE8 Standards modes of IE9, a property with the name “caller” is created. This caller property stores the reference to the argument object of the function that called it.

在下例中,IE8 和Quirks 中的所有文件模式,以及IE9 的IE7 标准和IE8 标准文件模式会传回“1”。 IE9 标准模式会发出「Object为null 或未经定义」的错误。

In the following example, all document modes in IE8 and Quirks, IE7 standards, and IE8 standards document modes in IE9 return “1”. IE9

standards mode issues the script error “object is null or undefined”.

function alertCallerLength()

{

alert();

}

function callingFunction()

{

alertCallerLength();

}

callingFunction(1);

解决方案及正确写法:

停用用此属性即可。

有关资源:

不再支持使用不带“.call”或“.bind”的函数指针调用方法。

MSDN原文:Calling a Method with a Function Pointer without ".call" or ".bind"

所属分类

Javascript and DOM

版本更新

IE8-IE9

具体描述及示例:

旧版IE中,为了使JavaScript 代码更加精简,常见的做法是将常用的方法储存为变量,然后将该变量替代该方法来使用:

d("