IE7 mode IE8兼容视图与独立IE7的区别详解( 三 )


meta http-equiv=X-UA-Compatible content=IE=EmulateIE7 /
If you are having problems, I’d suggest first checking you have a legitimate doctype in your HTML (the simplest one is !DOCTYPE html which forces standards mode). That will solve 90% of your problems, especially with IE6.
结论是:IE8兼容模式与独立的IE7是不同的,还是有些差异的,它并不是在IE8里简单包含了一个完整的IE7 。
四.具体差异的细节
1. Cross Document Communication
Hacks enabling cross-domain, cross-document communication have been disabled for security reasons.
解决方案:Use Cross Document Messaging (XDM) to work around this change.
2. 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.
event.source = myObject; // Read-only in IE8
解决方案: Change the names of conflicting custom properties to avoid collision.
event.mySource = myObject;
3. 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.
attr = elm.attributes[1]; // May differ in IE8
解决方案: Reference attributes by name as opposed to their position within the attributes collection.
attr = elm.attributes[id];
4. 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.

复制代码代码如下:
Try
{
elm.style.display = "table-cell";
} catch(e)
{
// This executes in IE7,
// but not IE8, regardless of mode
}

解决方案: 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.

推荐阅读