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.
推荐阅读
- IE7和IE8的兼容性问题
- IE7,6与Fireofx CSS对浏览器的兼容性性处理
- DIV+CSS相对IE6 IE7和IE8浏览器行为区别及兼容性问题整理
- IE7兼容模式可以解决IE8 FF浏览器下出现文字重叠问题
- 关于IE8兼容:X-UA-Compatible属性的解释
- 全面兼容ie6,ie7,ie8,ff的最简单的css写法
- 兼容性视图模式解决IE8浏览器下网页错位问题
- 修复网页在IE8 下的显示兼容问题
- Css样式兼容IE6,IE7,FIREFOX的浏览器的写法示例介绍
- 兼容IE6,IE8,FF 固定位置显示弹出层