IE6-IE9兼容性问题列表及解决办法.doc

上传人:wux****ua 文档编号:8943116 上传时间:2020-04-02 格式:DOC 页数:37 大小:1.74MB
返回 下载 相关 举报
IE6-IE9兼容性问题列表及解决办法.doc_第1页
第1页 / 共37页
IE6-IE9兼容性问题列表及解决办法.doc_第2页
第2页 / 共37页
IE6-IE9兼容性问题列表及解决办法.doc_第3页
第3页 / 共37页
点击查看更多>>
资源描述
IE6升级到IE9兼容性问题和操作手册2012/4/6 Bob Liu目录概述2第一章:HTML3第一节:IE7-IE8更新31.如果缺少结束标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素,会自动添加结束标记。32.支持格式正确的有效标记,不再支持格式错误的 HTML。4第二节: IE8-IE9更新51.表对象模式现在更加符合其他浏览器。52.文本布局使用自然度量而不是图形设备接口 (GDI) 度量。7第二章:CSS9第一节:IE6-IE7更新91.方框模型溢出内容现与方框相交,不再让方框自动增长适应内容。92.不再支持某些 CSS 筛选器(如 *HTML、_underscore 和 /*/ 注释)。113.已解决SELECT 元素不能被div覆盖的问题。14第二节:IE7-IE8更新141.不再支持 CSS 表达式,改为支持增强的 CSS 或 DHTML 逻辑。142.currentStyle 对象的Unset属性现在返回其初始值。153.style 对象的 Unset 属性值现在返回空字符串。16第三节:IE8-IE9更新171.泰语和东亚语文本和字体大小的显示可能小于其他字样。172.某些行为连接方法在 XML 模式中不可用。18第三章:Javascript and DOM19第一节:IE6-IE7更新191.不再允许用于绕过 window.close 提示的 window.opener 技巧。192.从脚本创建的模式或无模式对话框看起来似乎稍微变大。20第二节:IE7-IE8更新201.支持“class”语法,不再支持“className”属性语法。202.属性集合不再包含 Internet Explorer 可识别的所有可能属性。213.属性排序已更改,影响了属性集、innerHTML 和 outerHTML。224.GetElementById 区分大小写,且不再搜索名称属性。23第三节:IE8-IE9更新241.createElement 方法中不允许使用尖括号 。242.IE9 标准模式不支持arguments.caller 属性。243.不再支持使用不带“.call”或“.bind”的函数指针调用方法。254.不再连接内容属性和 DOM expando。275.JavaScript 属性列举在IE9 中不同。286.数学精确度在IE9 中不同。297.间接“eval”函数调用的行为方式不同。308.IE9 处理含大型索引的数组项目的方式不一样。319.重叠元素会被复制。3210.DOM中会保留空格。3311.部分DOM 事件已过时。35第四章:其他更新36第一节:IE7-IE8更新361.文件上载控件仅向服务器提交文件路径,而不提供完整路径。36第二节:IE8-IE9更新371.预设使用者代理(UA) 字串已变更.37概述本文档内容涵盖:IE6升级到IE9过程中Javascript, DOM, HTML, CSS等方面的变化和调整。 参考依据MSDN:1. Appendix 1: Internet Explorer 6 to Internet Explorer 9 Browser Changeshttp:/technet.microsoft.com/en-us/library/gg699425.aspx2. 附录 1:从 Internet Explorer 6 到 Internet Explorer 9 的浏览器更改http:/technet.microsoft.com/zh-cn/library/gg699425.aspx3. Internet Explorer 9 Compatibility Cookbookhttp:/msdn.microsoft.com/zh-cn/library/ff986083(v=vs.85).aspx4. 邊做邊學 IE9 相容性操作手冊http:/msdn.microsoft.com/zh-tw/ie/gg712396第一章:HTML第一节:IE7-IE8更新1. 如果缺少结束标记的 P 元素后跟 TABLE、FORM、NOFRAMES 或 NOSCRIPT 元素,会自动添加结束标记。 MSDN原文:Unclosed P elements are now automatically closed when followed by TABLE, FORM, NOFRAMES, or NOSCRIPT elements.所属分类版本更新HTMLIE7-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结构图如下:解决方案及正确写法:请注意此特性, 在代码中规避风险。2. 支持格式正确的有效标记,不再支持格式错误的 HTML。 MSDN原文:Malformed HTML is no longer supported, in favor of well-formed, valid markup.所属分类版本更新HTMLIE7-IE8具体描述及示例:支持格式正确的有效标记,不再支持格式错误的 HTMLMalformed 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下效果图如下:第二节: IE8-IE9更新1. 表对象模式现在更加符合其他浏览器。MSDN原文:Table Object Model Is Now More Consistent with Other Browsers.所属分类版本更新HTMLIE8-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 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.The getElementsByTagName and HtmlElement.children methods do not return comment nodes.如果不考虑这些变化在您的应用程序,应用程序可能会遇到次要的脚本错误,页面始终保持在加载中状态,或创建非预期内容等错误。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 function CheckTable() var table = document.getElementById(mytable); var tBodyResult = 有 + table.tBodies.length + 个tBodynn; var rows = table.rows; var length = rows.length; var rowResult = ; for (var i = 0; i length; i+) rowResult += 第 + (i+1) + 行: + rowsi.innerHTML + n; alert(tBodyResult + rowResult); Row1 Row2 Foot Head1 Head2 Click Me点击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.所属分类版本更新HTMLIE8-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 graphical device interface (GDI) metrics that other Microsoft Windows browsers use. GDI metrics align text to pixel boundaries, but natural metrics use inter-pixel spacing to create more accurately rendered and readable text. 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%).DoUse the following design guidelines to make sure that your webpages display text layout consistently:Set a text boxs 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.Test your webpages in all common browsers. If you see a text wrapping issue, adjust the page to make sure the page appropriately renders the text.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 notAvoid 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更新1. 方框模型溢出内容现与方框相交,不再让方框自动增长适应内容。MSDN原文:Box model overflow content now intersects box, no longer auto-grows box div to fit content.所属分类版本更新CSSIE6-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.请看下面的代码示例。div width : 100px; height: 100px; border: thin solid red;blockquote width: 125px; height: 100px; margin-top: 50px; margin-left: 50px; border: thin dashed blackcite display: block; text-align: right; border: nonep margin: 0; 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. 相关资源:http:/msdn.microsoft.com/en-us/library/bb250496(VS.85).aspx2. 不再支持某些 CSS 筛选器(如 *HTML、_underscore 和 /*/ 注释)。MSDN原文:Certain CSS filters (for example, *HTML, _underscore, and /*/ comment) are no longer supported.)所属分类版本更新CSSIE6-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 hacks). 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筛选器,停用即可。相关资源:3. 已解决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.所属分类版本更新CSSIE6-IE7具体描述及示例:Select元素现在已改为无窗口控件, 这项改变使z-order 和 zoom缩放能正常工作了,也就说, 这次彻底解决了IE6中Select不能被div覆盖的问题,除此之外,其他都和以前保持一致;但是,如果有应用程序依赖从Select控件获取窗口的HWND就必须修改为使用DOM了,因为Select元素现在是无窗口控件,也就得不到HWND了。Select ElementThe 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 that 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 tophttp:/blogs.msdn.com/b/ie/archive/2006/01/17/514076.aspx第二节:IE7-IE8更新1. 不再支持 CSS 表达式,改为支持增强的 CSS 或 DHTML 逻辑。MSDN原文:CSS expressions no longer supported, in favor of improved CSS support or DHTML logic.所属分类版本更新CSSIE7-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 */ var elm = document.getElementById(main); if(new Date().getHours()%2) elm.style.backgroundColor = #000; else elm.style.backgroundColor = #fff; 相关资源:2. currentStyle 对象的Unset属性现在返回其初始值。MSDN原文:Unset properties on the currentStyle object now return their initial value. This is the root cause of issues with the ASP.NET menu control.所属分类版本更新CSSIE7-IE8具体描述及示例:现在,currentStyle 对象的Unset 属性会返回其初始值”auto”, 这是 ASP.NET 菜单控件问题的根本原因。Unset properties on the currentStyle object now return their initial value. This is the root cause of issues with the ASP.NET 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 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 不能返回值。但是,如果用户指定了 ,currentStyle 和 STYLE 对象都将返回值 red。注释2:z-index 属性设置元素的堆叠顺序。拥有更高堆叠顺序的元素总是会处于堆叠顺序较低的元素的前面。解决方案及正确写法:例子:下面button不设置style属性(也就谈不上置width和zindex了),则currentStyle.width和currentStyle.zIndex都返回默认值auto.alert(window.document.getElementById(btnAdd).currentStyle.width);alert(window.document.getElementById(btnAdd).currentStyle.zIndex);要做如下双重检查:Perform a check for both the backwards compatible 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.html3. style 对象的 Unset 属性值现在返回空字符串。MSDN原文:Unset properties values on the style object now return empty string.所属分类版本更新CSSIE7-IE8具体描述及示例:style 对象的 Unset 属性值现在返回空字符串。Unset properties values on the style object now return empty string.Unspecified CSS Property ValuesUnset 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 = elm.style.zIndex; if(zIndex = 0) / custom code 解决方案及正确写法:要做如下双重检查:Perform a check for both the backwards compatible value and the empty string. var zIndex = elm.style.zIndex; if(zIndex = 0 | zIndex = ) / custom code 相关资源:第三节:IE8-IE9更新1. 泰语和东亚语文本和字体大小的显示可能小于其他字样。MSDN原文:Thai and East Asian Text and Font Sizing.所属分类版本更新CSSIE8-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 smallerThe specified font family did not support Thai or East Asian characters such as ArialThus, 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
展开阅读全文
相关资源
相关搜索

当前位置:首页 > 图纸专区 > 考试试卷


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!