Reports of broken sites are an important part of the feedback the IE team receives from the community. When we receive a report of a broken site, we take it and identify the core issue causing the problem. A number of these issues end up being side effects of changes we deliberately made in IE8, but even these are useful. They help us identify which IE8 changes have the broadest compatibility impact. In this post I'll share some of these issues with you so you can quickly identify problems affecting your site when migrating from IE7 to IE8.
Differences between IE8 Compatibility View and IE7
We strive to make Compatibility View behave as much like IE7 as possible, but we do make exceptions. Many of these exceptions enable improved security and accessibility features immediately, even for sites that have not yet migrated to IE8 Standards Mode.
Cross Document Communication
Hacks enabling cross-domain, cross-document communication have been disabled for security reasons. | SOLUTION: Use Cross Document Messaging (XDM) to work around this change. |
Extending the Event Object
IE exposes new properties for certain AJAX features such as Cross Document Messaging (XDM), even in Compatibility View. Adding custom properties to the Event object can conflict with these new properties, such as "source". | SOLUTION: Change the names of conflicting custom properties to avoid collision. |
event.source = myObject; // Read-only in IE8 | event.mySource = myObject; |
Attribute Ordering
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. | SOLUTION: Reference attributes by name as opposed to their position within the attributes collection. |
attr = elm.attributes[1]; // May differ in IE8 | attr = elm.attributes["id"]; |
Setting Unsupported CSS Values
Assigning CSS values that were unsupported in IE7 but are supported in IE8 Standards Mode will not generate exceptions in IE8 Compatibility View. Some sites use these exceptions to determine if a particular value for a CSS property is supported or not. | SOLUTION: Short of version detection, this is a difficult issue to work around. If this behavior is essential to a page, updating the page to run in IE8 Standards Mode may be the best approach. |
try { | |
Differences Between IE8 Standards Mode and IE8 Compatibility View
We see the majority of compatibility issues in IE8 Standards Mode. Most of these occur when sites expect legacy behavior that no longer exists in IE8 Standards Mode. Upgrading your site to run in IE8 Standards Mode is the best option in the long run, but in the interim you can quickly fix these types of issues by running your site in Compatibility Mode. This is described in Jefferson's post on the EmulateIE7 meta tag. In addition to the issues mentioned above, here's what you should be aware of.
Version Detection
While other changes are typically the root cause, version detection is where pages often go wrong. This is largely because making the right decision before a browser exists can be next to impossible. Nevertheless, incorrect version detection in conditional comments, script, and on the server side can easily break a page in IE8. This is especially true for conditional comments. They are used by a number of pages to apply fix-up CSS that IE8 no longer needs. | SOLUTION: Update pages to make appropriate version decisions. When possible, use object detection instead. |
<!--[if IE] | <!--[if lte IE 7] |
Object Detection
Object detection works great when used correctly. However some pages assume the existence of one feature based upon the presence of another, leading to problems when both features are not implemented in the same release. | SOLUTION: Perform proper object-detection for each feature used. |
if(window.postMessage) { | if(window.addEventListener) { |
Malformed HTML
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. | SOLUTION: Ensure your markup is well-formed and valid. | ||||||||||||||||||||||||||||||||
<ul> | <ul> Working with an Element's Class return elm.getAttribute("className"); return elm.getAttribute("class"); <div id="Test"></div> <div id="Test"></div> Generic CSS Prefix Selectors v\:* { v\:polyline, /* CSS */ /* Script */ if(!window.JSON) JSON = myJSON; JSON = myJSON; Initial CSS Property Values var zIndex = elm.currentStyle.zIndex; var zIndex = elm.currentStyle.zIndex; Unspecified CSS Property Values var zIndex = elm.style.zIndex; var zIndex = elm.style.zIndex; Attributes Collection var attr = elm.attributes["checked"]; var attr = elm.attributes["checked"]; That's all I have for now. If you encounter anything else you feel should be on the list, please add it to the comments to help others out. Tony Ross |
Комментариев нет:
Отправить комментарий