强制 IE7 进入标准渲染模式(不是怪癖)
由于 IE7 在怪异模式下渲染,我在 IE7 中遇到显示问题。我通过显示“document.compatMode”并返回“BackCompat”而不是“CSS1Compat”来确认这一点。使用 IE8 并恢复到 IE7 是可行的,因为这样可以避免出现异常情况。在普通的 IE8 中,我通过使用 X-UA-Compatible 标头强制渲染模式来修复它,但这不适用于 IE7。其他浏览器也会以怪异的方式显示,但与 IE 不同的是,这不会将它们置于伪 IE5.5 模式,因此它们仍然可以正常渲染。
如何强制 IE7 以标准渲染模式而不是怪异模式进行渲染?我尝试将 DOCTYPE 设置为许多不同的选项,但我没有添加 xml 序言。 预先感谢您的回复。
I'm having display issues in IE7 due to it rendering in quirks mode. I've confirmed this by displaying "document.compatMode" and getting back "BackCompat" as opposed to "CSS1Compat". Using IE8 and reverting to IE7 works, because that keeps it out of quirks. In plain IE8 I have it fixed by forcing the rendering mode with the X-UA-Compatible header, but this does not work for IE7. The other browsers also display in quirks, but unlike IE this does not put them into pseudo-IE5.5 mode, so they still render fine.
How can I force IE7 to render in standards rendering mode and not quirks? I've tried setting the DOCTYPE to a number of different options and I'm not adding the xml prologue.
Thanks in advance for any replies.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您尝试过 XHTML 4 严格的 DTD 吗?
另请注意,如果 DTD 声明之前有任何内容,IE7 仍将处于怪异模式。
换句话说:
IE7: strict
或
IE7: quirk
令人讨厌的地方在于: IE6 采用以下方式作为 Quirk 模式。
Did you try to the XHTML 4 strict DTD ?
Also beware that if there is anything before that DTD declaration, IE7 will still stay in quirk mode.
In other words:
IE7: strict
or
IE7: quirk
Where it gets nasty is that : IE6 takes the following as Quirk mode.
您是否通过 W3C 验证器运行代码?
如果 HTML 无效,无论文档类型如何,IE 都可能恢复到怪异模式。
Have you run your code through the W3C validator?
If you have invalid HTML, IE may revert to quirks mode regardless of the doctype.