IE6升级到IE11兼容性问题和操作手册

2015/3/2 Bob Liu

目录

概述... 2

第一章:HTML. 3

第一节:IE7-IE8更新... 3

1. 如果缺少结束标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素,会自动添加结束标记。 3

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

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

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

第二节: IE8-IE9更新... 7

1. 表对象模式现在更加符合其他浏览器。... 7

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

第二章:CSS. 11

第一节:IE6-IE7更新... 11

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

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

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

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

5.Style中的height,width结尾需要输入单位,如px. 16

第二节:IE7-IE8更新... 17

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

第三节:IE8-IE9更新... 18

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

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

第四节:IE9-IE10更新... 20

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

第三章:Javascript and DOM.. 21

第一节:IE6-IE7更新... 21

1. 不再允许用于绕过 window.close 提示的window.opener 技巧。... 21

2. 从脚本创建的模式或无模式对话框看起来似乎稍微变大。... 21

第二节:IE7-IE8更新... 22

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

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

3. 属性排序已更改,影响了属性集、innerHTML 和outerHTML。... 24

4. GetElementById区分大小写,且不再搜索名称属性。... 24

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

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

第三节:IE8-IE9更新... 27

1. createElement 方法中不允许使用尖括号<> 。... 27

2. IE9 标准模式不支持arguments.caller 属性。... 28

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

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

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

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

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

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

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

10. DOM中会保留空格。... 37

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

第四节:IE10-IE11更新... 39

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

2. 已删除window.execScript,改用eval。... 39

3. 已删除window.doScroll,改用window.scrollLeft、window.scrollTop。... 39

4. 已删除document.all,改用document.getElementById。... 40

5. 已删除document.fileSize、img.fileSize,使用 XMLHttpRequest 可提取源。... 40

6. 已删除script.onreadystatechange 和 script.readyState,改用script.onload。... 40

7. 已删除document.selection,改用window.getSelection。... 40

8. 已删除document.createStyleSheet,改用document.createElement("style")。... 40

9. 已删除style.styleSheet,改用style.sheet。... 40

10. 已删除window.createPopup,改用 div 或iframe(zIndex 值很高)。... 40

第四章:其他更新... 40

第一节:IE7-IE8更新... 40

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

第二节:IE8-IE9更新... 41

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

概述

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

参考依据MSDN:

1.     Appendix 1: Internet Explorer 6 to Internet Explorer 9 BrowserChanges

http://technet.microsoft.com/en-us/library/gg699425.aspx

2.     附录 1:从 Internet Explorer 6 到 Internet Explorer 9 的浏览器更改

http://technet.microsoft.com/zh-cn/library/gg699425.aspx

3.     Internet Explorer 9 Compatibility Cookbook

http://msdn.microsoft.com/zh-cn/library/ff986083(v=vs.85).aspx

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

http://msdn.microsoft.com/zh-tw/ie/gg712396

5.     Internet Explorer 11 开发人员指南

https://msdn.microsoft.com/zh-cn/library/ie/bg182636(v=vs.85).aspx

第一章:HTML

第一节:IE7-IE8更新

1.    如果缺少结束标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素,会自动添加结束标记。

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

所属分类

版本更新

HTML

IE7-IE8

具体描述及示例

如果缺少结束标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素,会自动添加结束标记,即:TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素不能再嵌套在段落元素P中了。

考虑如下代码:

<html>

<head>

<title>Simple PElement Closing Example</title>

<meta http-equiv="X-UA-Compatible" content="IE8"/>

</head>

<body>

<p>This is thefirst paragraph</p>

<p style="margin-left:30px">This is another paragraph. <!-- P not closed -->

<table border="1px" cellpadding="2px">

<tr><td>This is atable cell.</td></tr>

</table>

<p>This is athird paragraph.</p>

</body>

</html>

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

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

解决方案及正确写法:

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

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

MSDN原文:Malformed HTML is no longer supported, in favor of well-formed, validmarkup.

所属分类

版本更新

HTML

IE7-IE8

具体描述及示例

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

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

Parser error correction for malformed HTMLhas changed in IE8 Standards Mode. Pages depending on the way IE7 performserror correction may encounter issues as a result.

<ul>

<li>1.1

<ul>

<li>1.1.1</li>

</li> <!—多了一个标记,will Closes1.1 in IE8, but not IE7 -->

<li>1.1.2</li>

</ul>

</li>

</ul>

在IE8下可以看到如下效果图:

解决方案及正确写法:

HTML标记写法要严谨。

Ensure your markup is well-formed andvalid.

<ul>

<li>1.1

<ul>

<li>1.1.1</li>

<!-- </li> -->

<li>1.1.2</li>

</ul>

</li>

</ul>

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

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

所属分类

版本更新

HTML

IE7-IE8

具体描述及示例

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

 

解决方案及正确写法:

需要为按钮设置type类型。

<button id="button1"type="button"  style="width:150px;height:50px">按钮</button>

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

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

不支持的属性截图如下:

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

<TABLE id="china" >

<COLGROUP>

<COL align="left" width="80"></COL>

<COL align="right" width="150" style=”display:none”></COL>

</COLGROUP>

<THEAD>

<TR>

<TH align="left" name="Heading 1">日期</TH>

<TH name="Heading 2">分数</TH>

</TR>

</THEAD>

<TBODY>

<TR>

<TD name="Date"></TD>

<TD name="Score"></TD>

</TR>

</TBODY>

</TABLE>

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

因此,我们只好放弃在colgroup, col中设置样式,转而直接在td, th中设置。

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

推荐资料:
HE1004: IE8(S) Firefox Chrome Safari 不再支持 COL 及 COLGROUP 元素的部分属性及为其设定的 CSS 特性http://www.w3help.org/zh-cn/causes/HE1004

HTML 5 <colgroup> 标签

http://www.w3school.com.cn/html5/tag_colgroup.asp

第二节: IE8-IE9更新

1.    表对象模式现在更加符合其他浏览器。

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

所属分类

版本更新

HTML

IE8-IE9

具体描述及示例

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

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

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

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

•使用getElementsByTagName和HtmlElement.children方法不返回注释节点。

To improve consistency between WindowsInternet Explorer and other browsers, the IE9 Standards mode includes thefollowing changes to the table object model:

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

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

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

•The getElementsByTagNameand HtmlElement.children methods do not return comment nodes.

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

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

考虑如下代码:

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Table Test</title>

<script type="text/javascript">

function CheckTable() {

var table = document.getElementById("mytable");

var tBodyResult = "有" +table.tBodies.length + "个tBody\n\n";

var rows = table.rows;

var length = rows.length;

var rowResult = "";

for (var i = 0; i < length; i++) {

rowResult +=  "第" + (i+1) + "行: "+ rows[i].innerHTML + "\n";

}

alert(tBodyResult + rowResult);

}

</script>

</head>

<body>

<table id="mytable" >

<tbody>

<tr><td>Row1</td></tr>

<tr><td>Row2</td></tr>

</tbody>

<tfoot>

<tr><td>Foot</td></tr>

</tfoot>

<thead>

<tr><td>Head1</td></tr>

</thead>

<thead>

<tr><td>Head2</td></tr>

</thead>

</table>

<button οnclick="CheckTable()">ClickMe</button>

</body>

</html>

点击Click Me按钮,IE8将弹出提示,显示有三个tBody, 实际上只有一个tbody,但是IE8将多余的一个thead和一个tfoot都各自单独计入一个tBody里了。而IE9则不会有这个问题,只显示有一个tBody。

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

解决方案及正确写法:

注意此特性,规避风险。

相关资源:

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

MSDN原文:Text Layout Uses Natural Metrics.

所属分类

版本更新

HTML

IE8-IE9

具体描述及示例

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

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

针对旧版文件模式所写的页面版面配置在IE9 中可能无法正确​​显示。 最常見的错误是未预期的文字換行,這可能会遮盖位于换行文字下方的元素。当文字方块沒有多余的水平空间或是当文字方块的大小与頁面上的其他元素(例如图形) 相连时,很可能会发生此错误。

For text layout in IE9 Standards mode,Windows Internet Explorer 9 uses natural metrics instead of the graphicaldevice interface (GDI) metrics that other Microsoft Windows browsers use. GDImetrics align text to pixel boundaries, but natural metrics use inter-pixelspacing to create more accurately rendered and readable text.

Other document modes for Windows InternetExplorer continue to use GDI metrics.

Page layouts that are written for earlierdocument modes might display incorrectly in Internet Explorer 9. The mostcommon error is unexpected text wrapping, which can cover elements that arebelow the wrapped text. This error is most likely when a text box does notinclude extra horizontal space or when the size of the text box is connected toanother 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, 含义如下例:

<input type="text"style="width:100px" />

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

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

Do

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

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

•Include extra space inyour text boxes and avoid tight spaces.

•Use non-staticallysized text boxes.

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

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

•Test your webpages inall common browsers. If you see a text wrapping issue, adjust the page to makesure the page appropriately renders the text.

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

Do not

Avoid the following designs for textlayout:

•Depend on font sizes torender the same way across browsers.

•Use static-sized text boxes.

相关资源:

第二章:CSS

第一节:IE6-IE7更新

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

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

所属分类

版本更新

CSS

IE6-IE7

具体描述及示例

在IE7中,为了适应CSS2.1 box model,微软修改了溢出的行为。溢出是用来描述当一个块元素的内容溢出它的区域时,这些内容是否被剪切掉的一种方法。默认情况下,内容不被剪切,也就是,它有可能呈现在区域以外。过去的IE不支持这个行为。内容总是需要适合区域的大小。想象一个宽和高都是100px的区域,如果内容小于100px,那么没有问题。如果内容超过了尺寸,我们需要自动增长区域大小来适合内容。

In IE7, we changed the behavior of overflowto align with the CSS2.1 box model. Overflow is describes as a method to specifywhether content of a block-level element is clipped when it overflows the box.The default is visible. This value (visible) indicates that content is notclipped, i.e. it may be rendered outside the box. IE in the past did notsupport 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 than100px then IE would follow the specifications. If the content exceeded the sizewe would auto-grow the box to fit the content. To demonstrate this behavior,take a look at the following code sample.

请看下面的代码示例。

<style type="text/css">

div       { width : 100px; height: 100px; border: thin solid red;}

blockquote { width: 125px; height: 100px;

margin-top: 50px; margin-left: 50px;

border: thin dashed black}

cite      { display: block;

text-align: right;

border: none}

p         { margin: 0;}

</style>

<div>

<blockquote>

<p>some text long enough to make it interesting.</p>

<cite>- anonymous</cite>

</blockquote>

</div>

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

从图中可以看出,<blockquote>内容超出了div的边界,在IE7下,div不再自动增长来装下<blockquote>,而是让<blockquote>伸出div的边界。

As you can see, we now honor the height andwidth settings of a box. In this example, the <blockquote> content nowrenders outside of the boundaries of the parent <div> (box with redborders).

解决方案及正确写法:

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

If your layout relied on us"growing" the box (if your content did not fit the dimensions yougave it) then this can lead to breaks. You can easily discover breaks relatedto overflow by observing content suddenly overlapping other content.

相关资源:

http://msdn.microsoft.com/en-us/library/bb250496(VS.85).aspx

2. 不再支持某些 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 areavailable it is not a guarantee that all browsers render the same way. Thestandard might have undefined parts, not all components are equally implementedby all browser vendors, and existing implementations might have bugs. The CSSstandard does not provide a way to target specific browser versions and as aresult the Web developer community has developed CSS filters (also called"CSS hacks"). These filters take advantage of browser bugs orunimplemented features to hide CSS style rules from specific browsers. As wefix these bugs and improve CSS support, some CSS filters will stop working.

If you use such filters, you shouldunderstand their effects. In this long run, this will help you create designsthat more effectively adapt to improved CSS support in later versions ofInternet Explorer and other browsers.

In IE7, we fixed many underlying parserbugs that prevented the following filters from working in earlier versions ofIE. If your page contains these filters, please remove or replace them (at theend of this article we will offer other means of targeting reliable IEversions).

具体举例如下:

*HTML filter

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

/* The following rules used to apply onlyto

IEbut now get ignored by IE7 and higher */

* html{

}

* html body{

}

* html .foo{

}

下划线filter

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

/* The following rule used to applymin-height

tobrowser who understand this property and

height to IE.  In IE7, _heightwill be treated

asa 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 theheight

property to Internet Explorer. In IE7, the

value will be applied */

.myclass {

height/**/: 300px;

...

}

解决方案及正确写法:

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

相关资源:

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

MSDN原文:Applications that relied on SELECT element to get an HWND to use withMicrosoft Win32 APIs may break because SELECT element is now a windowlesscontrol.

所属分类

版本更新

CSS

IE6-IE7

具体描述及示例

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

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

Select Element—The Select control is now awindowless control. This change enables z-order and zoom to work correctly. TheHTML and Document Object Model (DOM) for Select remain the same, so Webdevelopers and end users interact with Select as before; however, applicationsthat relied on getting an HWND from Select to use with Microsoft Win32 APIsmust be modified to use the DOM.

 

解决方案及正确写法:

注意此特性即可。

相关资源:

Select control: CSS style-able and notalways on top

http://blogs.msdn.com/b/ie/archive/2006/01/17/514076.aspx

4. CSS样式区分大小写。

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

<html>

<head>

<meta http-equiv="X-UA-Compatible"content="IE=7"/>

<style type="text/css">

.field

{

background-color:blue/* ie 9*/

}

</style>

</head>

<body >

<p class="Field"> this is for div1</p>

<p style="background-color:blue"> this is for div2 </p>

</body>

</html>

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

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

<html>

<head>

<meta http-equiv="X-UA-Compatible"content="IE=6"/>

<script type="text/javascript">

functionload1() {

alert(document.getElementById("p1").style.height);

}

</script>

</head>

<body onload="load1()">

<p id="p1" style="background-color:blue; height:30">this is for div2 </p>

</body>

</html>

第二节:IE7-IE8更新

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

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

所属分类

版本更新

CSS

IE7-IE8

具体描述及示例

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

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

Support for CSS Expressions has beenremoved in IE8 Standards Mode.

CSS 表达式的例子:

#main {

background-color: expression(

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

);

}

解决方案及正确写法:

停用CSS Expressions,重构代码.

Refactor to utilize either improved CSSsupport or DHTML logic.

/* Script */

var elm =document.getElementById("main");

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

elm.style.backgroundColor = "#000";

} else {

elm.style.backgroundColor = "#fff";

}

相关资源:

第三节:IE8-IE9更新

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

MSDN原文:Thaiand 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 smallerin IE9 than in IE8 and earlier releases. In IE8, Thai and East Asian text couldbe rendered at a larger font size than specified when:

•The specified font sizewas 9pt or smaller

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

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

In IE9, the specified font size is alwaysrespected. Thus, as the fallback font is no longer scaled up, text may appearsmaller.

解决方案及正确写法:

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

此问题还会影响到多语言界面的CSS字体设置。

相关资源:

 

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

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

所属分类

版本更新

CSS

IE8-IE9

具体描述及示例

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

The markup-based form for connectingbehaviors works in Windows Internet Explorer 9 modes, but it does not work inxml mode.

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

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

<html xmlns:myNamespace>

<?importnamespace="myNamespace" implementation = "my.htc">

<myNamespace:calendar/>

此问题只影响新内容。

This problem affects only new content.

解决方案及正确写法:

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

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

<style>

.calendar {

-ms-behavior: url(my.htc);

}

</style>

<divclass="calendar"></div>

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

You canuse CSS-based registration through elements other than the class attribute.

相关资源:

第四节:IE9-IE10更新

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

所属分类

版本更新

CSS

IE9-IE10

具体描述及示例

htc文件将不再有效,全部被淘汰。

解决方案及正确写法:

具体解决方案请参考:

http://www.cnblogs.com/liuzhendong/archive/2013/01/09/2853823.html

http://www.cnblogs.com/liuzhendong/archive/2013/01/10/2855413.html

http://www.cnblogs.com/liuzhendong/archive/2013/01/12/2858067.html

相关资源:

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

http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/e548e698-13db-413b-94f7-730df24ad1ca

I don't think behaviors are supported inIE10 Standards mode....

you will find a complete comparison offeatures support in different IE versions and other browsers at the IE testingcenter...

http://samples.msdn.microsoft.com/ietestcenter/

Debugging your web apps using the DeveloperTools>Script or Console tab, should give a listing of warning and errormessages for unsupported features that have been ignored by the documentModethat you are using....

for backward compatibility with IE10 youcan add the IE9 x-ua meta or headers....

many of the htc behaviors have since beenreplaced by html5, css3 or js shims.. I would imagine there is no further needto support them in html5/css3 compliant browsers.

the Compatibility View setting...."Display intranet sites in compatibility view" allows legacy intranetdocuments to still use legacy features until such time as the corporatedevelopers update their intranet sites to 'Standards' compliant markup andlater versions of the css specs. If managing intranet sites that use htcbehaviors, your migration strategy should be to replace them with equivalentcss3 or js shims (jQuery, dojo, but not Extjs).

these are public peer to peer forums... wedo not work for nor represent MS.

第三章:Javascriptand DOM

第一节:IE6-IE7更新

1.    不再允许用于绕过 window.close 提示的window.opener 技巧。

MSDN原文:window.opener trick used to bypass the window.close prompt is no longerallowed.

所属分类

版本更新

Javascript and DOM

IE6-IE7更新

具体描述及示例

不再允许用于绕过 window.close 提示的 window.opener 技巧。

window.opener and window.close--InternetExplorer 7 no longer allows the window.opener trick to bypass the window.closeprompt. Browser windows cannot close themselves unless the windows were createdin script. This security enhancement no longer allows browsing to a random sitewhen the main browser window closes unexpectedly.

解决方案及正确写法:

在IE6中,当我们用这种方法:Response.Write("<script>window.close()</script>")

总是会提示:你查看的网页试图关闭的提示。在IE6下, 可以用以下方法,去掉提示,直接关闭窗体: Response.Write("<script>window.opener=null;window.close()</script>")

opener只要设为任何值都可以,不会出现提示。

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

注意此新特性即可。

相关资源:

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

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

所属分类

版本更新

其他

IE6-IE7更新

具体描述及示例

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

Changes that affect modal or modelessdialogs created from script--Modal or modeless dialogs created from script inInternet Explorer 7 might seem to be slightly bigger than their InternetExplorer 6 counterparts. This is caused by a change to the behavior of thedialogWidth and dialogHeight properties, which now set and retrieve dimensionsof the content area of a dialog (from Internet Explorer 7 and later). It willno longer be necessary to calculate the area lost by elements of a dialog’sframe.

解决方案及正确写法:

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

相关资源:

Why DoesIE Resize My Dialogs?

http://blogs.msdn.com/b/ie/archive/2006/08/25/719355.aspx

第二节:IE7-IE8更新

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

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

所属分类

版本更新

Javascript and DOM

IE7-IE8

具体描述及示例

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

In IE7, "className" had to beused as the attribute name to set and retrieve the class of an element. Thishas been fixed for standards-compliance in IE8 Standards Mode. Using the oldapproach will create an attribute named "className" that has noaffect on the actual class assigned to an element.

return elm.getAttribute("className");

解决方案及正确写法:

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

return elm.getAttribute("class");

例子:

function GetClass()

{

alert(window.document.getElementById("btnAdd").getAttribute("className"));

//alert(window.document.getElementById("btnAdd").getAttribute("class"));

}

<body οnlοad="GetClass()">

<form id="form1" runat="server">

<div>

<input type="button" id="btnAdd"value="123" class="INPUT" />

</div>

</form>

</body>

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

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

相关资源:

 

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

MSDN原文:The attributes collection no longercontains all possible attributes recognized by Internet Explorer.

所属分类

版本更新

Javascript and DOM

IE7-IE8

具体描述及示例

属性集合不再包含 InternetExplorer 可识别的所有可能属性.

The attributes collection no longercontains all possible attributes recognized by Internet Explorer.

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

例如:

var attr =elm.attributes["checked"];

// Potential script error in IE8

return attr.specified;

解决方案及正确写法:

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

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

正确写法:

var attr =elm.attributes["checked"];

if(attr) return attr.specified;

else return false;

相关资源:

3.     属性排序已更改,影响了属性集、innerHTML 和 outerHTML。

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

所属分类

版本更新

Javascript and DOM

IE7-IE8

具体描述及示例

属性排序已更改,影响了属性集、innerHTML和 outerHTML。

Attribute ordering has changed, affectingattributes collection, innerHTML, and outerHTML.

The ordering of attributes has changed,affecting the attributes collection as well as the values of innerHTML andouterHTML. Pages depending on a specific attribute ordering may break.

attr = elm.attributes[1]; // May differ inIE8

解决方案及正确写法:

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

Reference attributes by name as opposed totheir position within the attributes collection.

attr = elm.attributes["id"];

相关资源:

4.    GetElementById 区分大小写,且不再搜索名称属性。

MSDN原文:GetElementById is case sensitive and no longer searches nameattributes.

所属分类

版本更新

Javascript and DOM

IE7-IE8

具体描述及示例

GetElementById 区分大小写,不再搜索名称属性

GetElementById is case sensitive and nolonger searches name attributes.

The method getElementById is nowcase-sensitive and no longer searches name attributes.

<div id="Test"></div>

<script type="text/javascript">

// No element is found because of case difference

var test = document.getElementById("test");

</script>

解决方案及正确写法:

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

Ensure case-correctness and usegetElementsByName when searching name attributes.

<div id="Test"></div>

<scripttype="text/javascript">

// Element Test is found

var test = document.getElementById("Test")

</script>

相关资源:

 

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

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

所属分类

版本更新

CSS

IE7-IE8

具体描述及示例

现在,currentStyle 对象的Unset 属性会返回其初始值”auto”,这是 ASP.NET 菜单控件问题的根本原因。

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

Initial CSS Property Values

Unset properties on the currentStyle objectnow return their initial value. Relying on the old initial values for CSSproperties such as z-index can cause problems. This is the root cause of issueswith the ASP.NET menu control.

var zIndex = elm.currentStyle.zIndex;

if(zIndex == 0) {

// custom code

}

注释1:currentStyle 对象,它用来返回元素上的样式表,但是 style 对象只返回通过 STYLE 标签属性应用到元素的内嵌样式。因此,通过 currentStyle 对象获取的样式值可能与通过style 对象获取的样式值不同。例如,如果段落的color 属性值通过链接或嵌入样式表设置为红色( red),而不是内嵌的话,对象.currentStyle.color 将返回正确的颜色,而对象 style.color 不能返回值。但是,如果用户指定了<P STYLE="color:'red'">,currentStyle 和 STYLE 对象都将返回值 red。

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

解决方案及正确写法:

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

<input type="button"id="btnAdd" value="123" class="INPUT"  />

alert(window.document.getElementById("btnAdd").currentStyle.width);

alert(window.document.getElementById("btnAdd").currentStyle.zIndex);

要做如下双重检查:

Perform a check for both the backwardscompatible value and the standardized initial value.

var zIndex = elm.currentStyle.zIndex;

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

// custom code  }

相关资源:

currentStyle 对象

http://www.phpx.com/man/dhtmlcn/objects/currentStyle.html

6.    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 objectnow return empty string.

Unspecified CSS Property Values

Unset properties on the style object nowreturn the empty string for improved compliance with the DOM Level 2 StyleSpecification. Expecting CSS properties such as z-index to have a value whenthey have not been explicitly set can lead to problems.

var zIndex = elm.style.zIndex;

if(zIndex === 0) {

// custom code

}

解决方案及正确写法:

要做如下双重检查:

Perform a check for both the backwardscompatible value and the empty string.

var zIndex = elm.style.zIndex;

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

// custom code

}

相关资源:

 

第三节:IE8-IE9更新

1.createElement 方法中不允许使用尖括号<> 。

MSDN原文:Angle Brackets Are Not Allowed in the createElementMethod.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

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

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

例如,下面的例子在IE9 模式中引发异常。
var el=document.createElement("<divid='myDiv'>");

解决方案及正确写法:

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

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

var elm =document.createElement("div");

elm.setAttribute("id","myDiv");

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

varparent=document.createElement("div");

parent.innerHTML="<divid='myDiv'></div>";

var elm=parent.firstChild;

或者,也可以将网页设定为IE9 以前的文件模式。

相关资源:

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

MSDN原文:IE9Standards Mode Does Not Support the arguments.caller Property.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

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

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

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

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

In the following example, all documentmodes in IE8 and Quirks, IE7 standards, and IE8 standards document modes in IE9return “1”. IE9 standards mode issues the script error “object is null orundefined”.

function alertCallerLength()

{
alert(arguments.caller.length);

}

function callingFunction()

{

alertCallerLength();

}

callingFunction(1);

解决方案及正确写法:

停用用此属性即可。

相关资源:

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

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

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

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

var d = document.writeln;

d("<scriptlanguage=VBScript>");

在IE9 中,需要有Object才能调用方法。window对象预设是在全域范围内提供(比如在上例中)。但是window对象并没有"writeln"的方法,因此会报告JavaScript「call Object无效」的错误信息。

Previous versions of Internet Explorersupported caching a pointer to a method and then using the cached pointer tocall the method. This support was removed in Internet Explorer 9 in order toincrease interoperability with other browsers.

A common practice on webpages targetingolder versions of IE was to save common methods to a variable and use thatvariable as a proxy for the method in order to make JavaScript code morecompact:

var d = document.writeln;

d("<scriptlanguage=VBScript>");

In IE9, an object is required in order toinvoke the method. By default the "window" object is provided inglobal scope (such as in the previous example). However, the "window"object does not have a method "writeln" and so the JavaScript errormessage "Invalid calling object" is reported.

解决方案及正确写法:

简单解决此问题的方法是使用"call"方法(所有函数的属性) 明确提供适当的呼叫Object:

d.call(document, "<scriptlanguage=VBScript>");

长期解决此问题的方法是使用JavaScript 的"bind" API,建立隐含的呼叫Object与方法的关联。方法如下(同样是取自上例):

var d = document.writeln.bind(document);

d("<scriptlanguage=VBScript>"); // Now this is OK

原文:

Now you must specify the target for themethod call just as you do in all other browsers. So while this code works inIE8 and earlier:

var d = document.writeln;

d("<scriptlanguage=VBScript>");

Now it fails in IE9 just as it fails in allother browsers. An easy fix for this issue is to use the "call"method (a property of all functions) to explicitly provide the appropriatecalling object:

d.call(document, "<scriptlanguage=VBScript>");

The long term fix for this is to useJavaScript's "bind" API to associate an implicit calling object withthe method. This is done as follows (again, drawing on the previous example):

var d = document.writeln.bind(document);

d("<scriptlanguage=VBScript>"); // Now this is OK

相关资源:

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

MSDN原文:Content Attributes and DOM Expandos Are No Longer Connected.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

例如:

<divid="myElement" class="b"myAttr="custom"></div>

在下面的范例中,'id' 和'className' 都是预先定义的属性:

var div = document.getElementById("myElement");

var divId = div.id; // Gets the value ofthe id content attribute

var divClass = div.className; // Gets thevalue of the class content attribute

在IE8 和之前的版本中,'myAttr' 内容属性的存在等于暗示'myAttr'DOM expando 的存在:

var divExpando = div.myAttr; // divExpandowould get the value "custom" in IE8

IE9 中的突破性变更是使用者定义的内容属性将不再暗指DOM expando。

var divExpando = div.myAttr; // divExpandowould get an undefined value

In past versions of Internet Explorer,content attributes were represented on JavaScript objects as DOM expandos. InInternet Explorer 9, this link between content attributes and DOM expandos hasbeen severed in order to increase interoperability between IE and otherbrowsers.

A content attribute is an attribute that isspecified in the HTML source, for example, <elementattribute1="value" attribute2="value">. Many contentattributes are predefined as part of HTML; HTML also supports additionaluser-defined content attributes.

DOM expandos are the values that can beretrieved from an object in JavaScript, for example,document.all["myelement"].domExpando. Most objects have a predefinedset of properties that typically represent the value of their same-namedcontent attribute. JavaScript supports additional user-defined properties aswell.

解决方案及正确写法:

在JavaScript 代码中几乎无法直接在失败点看出此问题。而往往是在应用时才会看到失败的情形。

若要修正此问题,请使用'getAttribute'来获取使用者定义的内容属性值。建议对所有IE 版本采取此因应措施。例如(根据上个范例):

不要使用:

var divExpando = div.myAttr;

而改用:

vardivExpando = div.getAttribute("myAttr");

相关资源:

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

MSDN原文:JavaScript Property Enumeration Differs in Internet Explorer 9

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

由于IE9 的JavaScript Object模型中所做的变更,JavaScript属性的列举方式跟在IE8 中可能不太一样。

Due to the changes made in the JavaScriptobject model of Internet Explorer 9, JavaScript properties may be enumerateddifferently from how they are enumerated in Internet Explorer 8.

当在任何文件模式内使用for…陈述式时,属性列举的顺序可能与IE8 传回的顺序不同。例如,数值属性现在是列举在非数值属性之前。下例说明IE8 与IE9 之间的列举顺序的差异:

When using the for…in Statement, in anydocument mode, the order of property enumerations may be different from theorder returned by Internet Explorer 8. For example, numeric properties nowenumerate before non-numeric properties. The following sample illustrates thedifference in enumeration order between Internet Explorer 8 and InternetExplorer 9:

var obj = {first : "prop1",second: "prop2", 3: "prop3"};

var s = "";

for (var key in obj) {

s+= key + ": " + obj[key] + " ";

}

document.write (s);

在IE8 和IE9 中执行此范例会输出下列结果:

IE8:first: prop1 second: prop2 3: prop3

IE9:3: prop3 first: prop1 second: prop2

IE8 并不包含与原型物件的内建属性同名的属性列举。 IE9 中的所有文件模式則会在列举中包含這些属性。

Internet Explorer 8 does not includeenumerations of properties that have the same name as built-in properties of aprototype object. All document modes in Internet Explorer 9 include theseproperties in the enumeration. The following sample illustrates thisdifference:

下列说明此项差异:

var obj = { first: "prop1",toString : "Hello" }

var s = "";

for (var key in obj) {

s+= key + ": " + obj[key] + " ";

}

document.write (s);

在IE8 和IE9 中执行此范例会输出下列结果:

IE8的所有模式: first: prop1 first: prop1

IE9的所有模式: first: prop1 toString: Hello

解决方案及正确写法:

需要注意此项差异并修改受影响代码。

相关资源:

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

MSDN原文:Math PrecisionDiffers in Internet Explorer 9

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

数学精确度在某些边界情况下与IE8 不同。

Math precision differs from InternetExplorer 8 in certain edge cases.

Chakra 引擎使用Streaming SIMD Extensions 2 (SSE2) (如果平台有支援的话),达成更快速的数学运算,但是也会在精确度方面产生有别于IE8 的JScript 引擎的差异。下列說明了這项差异:

The Chakra engine uses Streaming SIMDExtensions 2 (SSE2) if the platform supports them, which results in fastermathematical operations but also yields a difference in precision from theJScript engine of Internet Explorer 8. The following example demonstrates thedifference:

function test() {

var x = 6.28318530717958620000;

var val = Math.sin(x);

document.write(Math.abs(val))

}

test();

在IE8 的所有模式中,这会输出“2.4492127076447545e-16”。

当平台支持SSE2 时,在IE9 的所有模式中,这会输出“2.4492935982947064e-16”。

In all modes of Internet Explorer 8, thiswill print “2.4492127076447545e-16”. When the platform supports SSE2, in allmodes of Internet Explorer 9, this will print “2.4492935982947064e-16”.

解决方案及正确写法:

需要注意此项差异。

相关资源:

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

MSDN原文:Indirect 'eval' FunctionCalls Behave Differently in Internet Explorer 9.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

间接“eval”函数调用,会在IE9 中产生与IE8 不同的结果。

Calling eval methods indirectly (that is,other than by the explicit use of its name) inside a function produces differentresults in Internet Explorer 9 than it does in Internet Explorer 8.

在IE8 和Quirks 的所有模式中,以及IE9 的IE 7 标准和IE8 标准模式中,传递给间接eval 的字串是在本机函数范围内进行评估。在IE9 的IE9 标准模式中,则是根据ECMAScript 标准(第5 版) 在全域范围内进行评估。

In all modes of Internet Explorer 8 andQuirks, IE 7 standards, and IE8 standards modes of Internet Explorer 9, thestring passed to the indirect eval is evaluated in the local function scope. InIE9 Standards mode of Internet Explorer 9, it is evaluated in the global scopeas per the ECMAScript standard (5th edition).

在下例中,是通过将eval 函数赋值给变量并且把该变量当作eval 来调用的方式,间接调用eval 函数。

In the following example, the eval functionhas been called indirectly by assigning it to a variable and calling thevariable as if it were eval.

function test() {

var dateFn = "Date(1971,3,8)";

var myDate;

var indirectEval = eval;

indirectEval("myDate = new " + dateFn + ";");

document.write(myDate);

}

test();

本范例在IE8 和Quirks 的所有模式中,以及IE9 的IE 7 标准和IE8 标准模式中将传回“Thu Apr 8 00:00:00 PDT 1971”。而在IE9 的IE9 标准模式中,这会输出“undefined”。

This sample will return “Thu Apr 8 00:00:00PDT 1971” in all document modes of Internet Explorer 8 and Quirks, IE7standards, and IE8 standards document modes in Internet Explorer 9. However inIE9 standards mode of Internet Explorer 9, this would print “undefined”

解决方案及正确写法:

需要注意此项差异。

相关资源:

 

 

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

MSDN原文:Array elements with largeindices are handled differently than in Internet Explorer 8.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

含大型索引的数组项目的处理方式与IE8 不同。

Array elements with large indices arehandled differently than in Internet Explorer 8.

在数组的length 属性的初始值大于2E+31-1 (亦即2147483647) 的情况下,IE8 并不符合ECMAScript (第3 版) 规格。当使用大于2147483647 的索引建立数组项目时,新建立项目的索引将会是负整数。

Internet Explorer 8 does not conform to theECMAScript (3rd edition) specification in situations where the initial value ofthe array’s length property is greater than 2E+31-1 (that is, 2147483647). Whenan array element is created with an index greater than 2147483647, the index ofnew element created will be a negative integer.

IE9 会正确处理使用介于2E+31-1 和2E+32-2 指数之间的数组项目。 IE9 的任何文件模式中并未复写IE8 行为。

Internet Explorer 9 correctly handles arrayelements that use indices between 2E+31-1 and 2E+32-2. The Internet Explorer 8behavior is not replicated in any of the Internet Explorer 9 document modes.

当项目推送到长度为2E+31-1 的数组时,即可观察到此现象。

This can be observed when an element ispushed to an array of length 2E+31-1.

下例在IE8 输出“true”,但是在IE9 输出“false”。

The following sample prints “true” inInternet Explorer 8, but prints “false” in Internet Explorer 9.

function test() {

var arr = new Array();

arr[2147483650] = 10000;

arr.push(10);

document.write(arr["-2147483645"] == 10);

}

test();

解决方案及正确写法:

需要注意此项差异即可。

相关资源:

9.    重叠元素会被复制。

MSDN原文:Overlapping ElementsAre Cloned.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

在IE9 中,重叠的格式化元素是会被复制的,其用意是为了减低在DOM (Document Object Model) 中语意模糊的情况。

一般来说,网站有没有这项功能看起来都一样。不过,若是您对标记中的重叠元素执行DOM 操作,该动作在IE9 中的运作方式可能不一样。

举例来说,假如您对重叠元件进行像是firstChild或nextSibling这类的DOM呼叫,这些呼叫可能不会以相同的方式运作。

Overlapping formatting elements are clonedin Windows Internet Explorer 9 to reduce ambiguity in the Document Object Model(DOM).

Typically, a site looks the same with orwithout this feature. However, if you perform DOM operations on elements thatare overlapped in markup, the operations might not work the same way inInternet Explorer 9.

For example, if you make DOM calls such asfirstChild or nextSibling on an overlapped element, these calls might not workthe same way.

解决方案及正确写法:

不过此问题的优先级为”Low”,所以我们可以不必太在意。

使用IE开发者工具来测试您的程式码,以找出并修正所有的重叠元素。

Testyour code by using the Internet Explorer Developer Tools to find and fix anyoverlapping elements.

相关资源:

 

10.  DOM中会保留空格。

MSDN原文:White Spaces Are Preserved inthe Document Object Model.

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

您新增的任何空白字符都会保存在DOM中。

Any white space that you add to a webpagepersists in the Document Object Model (DOM).

請考虑下面的例子在IE9 与IE8 中的差异。

Consider how the following code exampleappears in Windows Internet Explorer 9 and Windows Internet Explorer 8.

<div>

Text </div>

IE9:

div

|->"\n Text "

IE8:

div

|->"Text"

考虑如下代码:

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head>

<title></title>

</head>

<body>

<div>

<input type="input" id="t1" value="t1"/>

</div>

</body>

</html>

在IE8下文档结构图如下:

在IE9下文档结构图如下:

解决方案及正确写法:

请留意代码中的空格。

相关资源:

11.  部分DOM 事件已过时。

MSDN原文:SomeDOM Events Are Deprecated。

所属分类

版本更新

Javascript and DOM

IE8-IE9

具体描述及示例

部分DOM 事件已过时。

Microsoft identifies features asdeprecated to warn against using the features in the future so that they can bephased out:

•If new standards-based support isadded in Windows Internet Explorer 9, the associated feature documentation onMSDN is marked with "deprecated" and includes a link to the standards-basedalternative.

•If the feature is a web platformfeature, it is supported across all document modes until the feature is shownto be used by very few websites.

The following Document Object Model (DOM) events features are deprecated in IE9 standards document mode and are intended to be removed in the latest standards mode of the next major release.

Deprecated feature

W3C standards replacement

attachEvent

addEventListener

detachEvent

removeEventListener

createEventObject

createEvent

fireEvent

dispatchEvent

解决方案及正确写法:

建议写法:

<htmlxmlns="http://www.w3.org/1999/xhtml">

<head id="Head1"runat="server">

<scripttype="text/javascript">

function LoadEverything() {

//应停用过时方法

//document.getElementById("btnAdd").attachEvent("onclick",ShowHello);

//应用标准方法,注意事件不是onclick,而是click.

document.getElementById("btnAdd").addEventListener("click",ShowHello);

}

function ShowHello() {

alert("hello");

}

</script>

</head>

<bodyοnlοad="LoadEverything()">

<form id="form1" runat="server">

<input type="button" id="btnAdd" value="btnAdd"  />

</form>

</body>

</html>

相关资源:

第四节:IE10-IE11更新

参考资料:https://msdn.microsoft.com/zh-cn/library/ie/bg182625(v=vs.85).aspx#legacyAPIs

1. 已删除attachEvent,改用addEventListener。

2. 已删除window.execScript,改用eval。

3. 已删除window.doScroll,改用window.scrollLeft、window.scrollTop。

4. 已删除document.all,改用document.getElementById。

5. 已删除document.fileSize、img.fileSize,使用XMLHttpRequest 可提取源。

6. 已删除script.onreadystatechange 和 script.readyState,改用script.onload。

7. 已删除document.selection,改用window.getSelection。

8. 已删除document.createStyleSheet,改用document.createElement("style")。

9. 已删除style.styleSheet,改用style.sheet。

10.     已删除window.createPopup,改用 div 或 iframe(zIndex 值很高)。

 

第四章:其他更新

第一节:IE7-IE8更新

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

MSDN原文:File upload control only submits the filepath, not the full path, to the server.

所属分类

版本更新

其他

IE7-IE8更新

具体描述及示例

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

Historically, the HTML File Upload Control(<input type=file>) has been the source of a significant number ofinformation disclosure vulnerabilities. To resolve these issues, two changeswere made to the behavior of the control.

To block attacks that rely on “stealing”keystrokes to surreptitiously trick the user into typing a local file path intothe control, the File Path edit box is now read-only. The user must explicitlyselect a file for upload using the File Browse dialog.

Additionally, the “Include local directorypath when uploading files” URLAction has been set to "Disable" forthe Internet Zone. This change prevents leakage of potentially sensitive local file-systeminformation to the Internet. For instance, rather than submitting the full pathC:\users\ericlaw\documents\secret\image.png, Internet Explorer 8 will nowsubmit only the filename image.png.

解决方案及正确写法:

注意此特性即可。

相关资源:

http://blogs.msdn.com/b/ie/archive/2008/07/02/ie8-security-part-v-comprehensive-protection.aspx

第二节:IE8-IE9更新

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

MSDN原文:DefaultUser-Agent (UA) String Changed.

所属分类

版本更新

其他

IE8-IE9

具体描述及示例

IE9 使用缩短的UA使用者代理字符串, 不会再传送安装在电脑上的其他软件所新增的UA 字串,例如.NET Framework 。

By default, Internet Explorer 9 sends a newshort UA string to improve the overall performance, interoperability, andcompatibility. Internet Explorer 9 does not send additions to the UA stringthat are made by other software that is installed on the computer, such as the.NET Framework and many other programs.

IE7: Mozilla/4.0 (compatible; MSIE 7.0;Windows NT 6.0; Trident/5.0; SLCC1; .NET CLR 2.0.50727; .NET CLR 3.0.30729;.NET CLR 3.5.30729; .NET4.0C; .NET4.0E)

IE9: Mozilla/5.0 (compatible; MSIE 9.0;Windows NT 6.1; Trident/5.0)

解决方案及正确写法:

需要注意此项差异。

相关资源:

IE6升级到IE11兼容性问题和操作手册相关推荐

  1. IE8升级为IE11兼容性错误及解决方法总结

    最近几个月一直在做IE升级的项目,在此,记录下项目中遇到的问题和解决方法. 首先项目原版本为IE8,要升级到的版本为IE11,由于IE在升级过程中不断的摒弃一些方法和更新一些方法,所以按照老版本IE编 ...

  2. html如何设置ie6兼容性视图,ie6浏览器设置兼容性视图的操作步骤

    当前很多网友才刚刚使用ie6浏览器,还不熟悉设置兼容性视图的操作,那么ie6浏览器如何设置兼容性视图呢?接下来小编就来讲解ie6浏览器设置兼容性视图的操作步骤,相信一定可以帮助到你们. 打开浏览器后, ...

  3. xp电脑对ajax的兼容性,xp系统iE11兼容性问题的详细技巧

    xp系统iE11兼容性问题的详细技巧?我们在操作xp系统电脑的时候,常常会遇到xp系统iE11兼容性问题的问题.那么出现xp系统iE11兼容性问题的问题该怎么解决呢?很多对电脑不太熟悉的小伙伴不知道x ...

  4. win7ie11调用java失败,不忘旧人,四招轻松解决Win7系统IE11兼容性问题

    Win7之家( www.win7china.com):不忘旧人,四招轻松解决Win7系统IE11兼容性问题 IE11是IE最高版本的浏览器,也可能是微软最后一个版本的IE浏览器啦,在Win10系统中作 ...

  5. html在ie8下跳转新网址,ie8升级到ie11 单击“查看已安装更新”

    IE升级不是版本越高越好,要适合当前系统的才是最好的. 您可以试试[百度电脑专家]一键修复升级. IE 升级到11, 想恢复到IE8 如何设置 首先打开IE11浏览器,然后点击上面的"工具& ...

  6. IE11兼容性问题——网站提示“打印插件只支持IE浏览器”

    很多系统已经自动升级到IE11,会出现兼容性问题--网站提示"打印插件只支持IE浏览器" 解决方法: 浏览器"工具"--"兼容性视图设置", ...

  7. SharePoint2010升级到SharePoint2013操作手册

    SharePoint2010升级到SharePoint2013操作手册 目 录 第一章 前言    3 第二章 升级前准备    3 第三章 升级流程图    5 第四章 升级过程    5 4.1 ...

  8. win7系统下IE9升级到IE11后开发者工具下的网络和探查器显示空白问题

    前段时间为了测试将win7系统下IE9升级到IE11,之后F12打开开发者工具后网络和探查器显示一片空白,先是按网上资料上说的安装补丁:https://www.microsoft.com/en-us/ ...

  9. 橘子CPS联盟操作手册2021.09

    橘子CPS联盟操作手册2021.09 目录 橘子CPS联盟操作手册2021.09 橘子CPS联盟是干嘛的 橘子CPS基本操作流程 PC端操作 1.注册 2.登陆 3.渠道管理 4.分享网站 5.分享网 ...

  10. 中关村-DIY电子书之Nook2 Root 完全操作手册

    Nook2Root 完全操作手册 一.备份 1.准备工作 一张TF内存卡+读卡器(建议256MB以上).Win32DiskImager(用于把镜像文件写入内存卡里以制造引导盘).noogie.img( ...

最新文章

  1. Frida 基础操作2
  2. CG-CTF-Web-/x00
  3. 一些前端开发经典书籍推荐和下载链接分享
  4. python输入list_python学习(list增删改查、及常用方法)
  5. myeclipse----JVM运行内存溢出问题解决
  6. Android APK系列5-------修改APK中的内容
  7. 自动更改IP地址反爬虫封锁,支持多线程(转)
  8. maven 配置远程仓库服务器密码
  9. UnityShader[3]屏幕后处理学习笔记
  10. java网上书店模板_网上书店静态网站模板
  11. Makefile 编写规则
  12. [笔记分享] [Camera] 相机的flash led功能小结
  13. 30分钟了解DNS及搭建方法
  14. 使用Session+Cookie实现7天免登录
  15. 情人节之Python版冰墩墩
  16. vs2013+opencv3.4.3配置安装教程
  17. 高德地图如何同时显示多个InfoWindow信息窗体
  18. 最长无重复子数组算法-java实现
  19. 高德地图轨迹回放、点的弹跳效果、浏览器环境监测、设置地图的主题样式、GPS坐标转为高德坐标、地图加载提示、地图DOM事件、修改图层等API接口
  20. 赫夫曼树的创建(思路分析)

热门文章

  1. OJ刷题二——设计输出实数格式
  2. python中数组常用的统计方法
  3. 跨境电商如何利用Quora帮你引上万流量
  4. 咪咕阅读怎么下载小说
  5. 2012春晚节目清单:
  6. 移动设备播放局域网内的视频
  7. Python中7种随机函数总结
  8. windows下快速安装nginx并配置开机自启动的方法
  9. 程序员发布:一张图读懂支撑阿里双十一1682亿的技术架构体系
  10. 开放报名 | “2021 年全国人工智能大赛”正式开赛