有没有办法强制 IE8 中的页面以 IE7 怪异模式或 IE8 兼容视图怪异模式呈现?
注意:当我说“浏览器模式”和“文档模式”时,我指的是 IE8 开发人员工具菜单栏中的渲染选项。
我们注意到我们的 Internet 网站上存在奇怪的功能Explorer 8。当用户单击“添加到购物车”按钮时,将调用 jQuery .load()
方法来请求新网页,然后将其放置在 javascript“弹出”窗口中。在 IE7(以及 Firefox、Chrome 和 Safari)中,一切都运行良好。
但是,在 IE8 中,所有 元素(及其子元素)都隐藏在通过
.load()
加载的内容中。这只发生在 IE8 Quirks 模式(页面默认)中,而不会发生在 IE7 Quirks 模式中。
我知道我可以使用 或
标记告诉 IE8 应如何呈现文档,但这会强制页面呈现为 IE7 标准 < IE8“浏览器模式”中的 em>文档。
奇怪的是,我需要的是强制页面在 IE7 浏览器模式或 IE8 兼容性视图浏览器模式下以 Quirks 模式呈现。这可能吗?
这也引出了一个问题:IE8 怪异模式是否应该与 IE7 怪异模式相同?
NOTE: When I say "Browser Mode" and "Document Mode", I'm referring to the rendering options in the menu bar of IE8's developer tools.
We're noticing odd functionality on our website in Internet Explorer 8. When the user clicks the "Add to Cart" button, the jQuery .load()
method is called to request a new webpage that is then placed inside a javascript "pop up" window. Everything works great in IE7 (and in Firefox, Chrome, and Safari, for that matter).
However, in IE8, all <table>
elements (and their children) are hidden in the content that is loaded via .load()
. This only happens in IE8 Quirks Mode (default for the page) and not in IE7 Quirks Mode.
I know that I can use the <meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
or <meta http-equiv="X-UA-Compatible" content="IE=7" />
tags to tell IE8 how it should render the document, but this forces the page to render as an IE7 Standards document in IE8 "Browser Mode".
What I need, oddly enough, is to force the page to render in Quirks Mode in either the IE7 Browser Mode or IE8 Compatability View Browser Mode. Is this possible?
This also begs the questions: Is IE8 quirks mode supposed to be the same as IE7 quirks mode?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当浏览器处于 Quirks 模式时,您不能指望它有任何好处。让您的代码符合 html 标准,以便浏览器进入标准模式,然后您就可以开始查看您的 javascript 问题。
When a browser is in Quirks mode you can't expect anything good from it. Make your code compliant with the html standard so that the browser goes into standards mode and then you can start looking at your javascript problem.
Quirks 模式用于指当您未指定文档类型(或者指定非常旧的文档类型,请参阅 维基百科关于该主题的文章)。该渲染是基于IE5(或者5.5,我忘了是哪一个)。 IE7 和 IE8 之间没有变化。
如果您在 IE8 中以 IE7 或怪异模式呈现文档时遇到不同的行为,则这表明该问题与版本检查有关 - 因为这是浏览器模式控制的。如果您的版本检查不会将 IE8 与 IE7 区别对待,并且文档模式是 IE7 或怪异模式,那么您不应该看到任何差异。
Quirks mode is used to refer to the rendering you get when you don't specify a doctype (or you specify a really old doctype, see the table at Wikipedia's article on the topic). That rendering is based on IE5 (or 5.5, I forget which one). That is unchanged between IE7 and IE8.
If you are experiencing different behavior in IE8 when it's rendering the document in IE7 or quirks mode, then this suggests the issue is related to version checks - because that's what the Browser Mode controls. If your version checks don't treat IE8 differently than IE7, and the document mode is IE7 or quirks mode, then you're not supposed to see any differences.
我遇到了同样的问题,我发现 IE7 和 IE8 浏览器模式之间存在行为差异,这不是由版本检查引起的。当您尝试加载到innerHTML中的内容包含DOCTYPE时,在IE8浏览器模式下,表格内的内容将不会显示,但在IE7和IE7模式下会显示(所有这些仅适用于文档的怪异模式)模式)。以下 HTML 示例演示了该问题(文本“Inside Table”在 IE8 浏览器模式下不显示):
不幸的是,我还没有找到在 IE7 浏览器模式下获取怪异模式的方法。您可以通过执行“document.getElementById('content').innerHTML = document.getElementById('content').innerHTML”之类的操作来解决此问题,因为 DOCTYPE 和其他无关的部分已被解析出来,因此重置它会导致要再次显示的表格。
I am hitting this same issue, and I've found that there is a behavior difference between IE7 and IE8 browser mode that is not caused by version checking. When the content you are trying to load into an innerHTML includes a DOCTYPE, in IE8 browser mode, the content inside tables will not be displayed, but it will in IE7 and in IE7 mode (all of this applies only to quirks mode for the document mode). The following HTML sample demonstrates the problem (the text "Inside Table" does not display in IE8 browser mode):
Unfortunately I have not found a way to get quirks mode with IE7 browser mode. You can work around the issue by doing something like "document.getElementById('content').innerHTML = document.getElementById('content').innerHTML", because the DOCTYPE and other extraneous pieces have been parsed out, so resetting it causes the tables to display again.