简体   繁体   English

有没有一种方法可以强制IE8中的页面以IE7怪异模式或IE8兼容视图怪异模式呈现?

[英]Is there a way to force a page in IE8 to render in IE7 quirks mode or IE8 Compat View Quirks Mode?

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. 注意:当我说“浏览器模式”和“文档模式”时,我指的是IE8开发人员工具菜单栏中的渲染选项。

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. 我们注意到Internet Explorer 8网站上的功能异常。当用户单击“添加到购物车”按钮时,将调用jQuery .load()方法来请求一个新网页,然后将其放置在javascript中弹出”窗口。 Everything works great in IE7 (and in Firefox, Chrome, and Safari, for that matter). 一切都可以在IE7(以及Firefox,Chrome和Safari)中正常运行。

However, in IE8, all <table> elements (and their children) are hidden in the content that is loaded via .load() . 但是,在IE8中,所有<table>元素(及其子元素)都隐藏在通过.load()加载的内容中。 This only happens in IE8 Quirks Mode (default for the page) and not in IE7 Quirks Mode. 这仅在IE8 Quirks模式(页面的默认设置)下发生,而在IE7 Quirks模式下则不会发生。

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". 我知道我可以使用<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /><meta http-equiv="X-UA-Compatible" content="IE=7" />标记可告诉IE8如何呈现文档 ,但这会迫使页面在IE8“浏览器模式”下呈现为IE7标准文档

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. 奇怪的是,我需要强制页面在IE7浏览器模式或IE8兼容性视图浏览器模式下以Quirks模式呈现。 Is this possible? 这可能吗?

This also begs the questions: Is IE8 quirks mode supposed to be the same as IE7 quirks mode? 这也引出了一个问题:IE8 quirks模式是否应该与IE7 quirks模式相同?

When a browser is in Quirks mode you can't expect anything good from it. 当浏览器处于Quirks模式时,您不能指望它带来任何好处。 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. 使您的代码符合html标准,以便浏览器进入标准模式,然后即可开始查看JavaScript问题。

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 ). 当您未指定doctype(或指定了真正的旧doctype,请参阅Wikipedia上有关该主题的文章中的表)时,“怪癖”模式用于引用所获得的呈现。 That rendering is based on IE5 (or 5.5, I forget which one). 该渲染基于IE5(或5.5,我忘记了哪一个)。 That is unchanged between IE7 and IE8. IE7和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 . 如果您在IE8中以IE7或怪异模式呈现文档时在IE8中遇到不同的行为,则表明该问题与版本检查有关- 因为这是浏览器模式所控制的 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. 如果您的版本检查没有将IE8与IE7区别对待,并且文档模式为IE7或怪癖模式,则您不应看到任何区别。

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. 我遇到了同样的问题,并且我发现IE7和IE8浏览器模式之间的行为差​​异不是由版本检查引起的。 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). 当您尝试加载到innerHTML中的内容包括DOCTYPE时,在IE8浏览器模式下,表内的内容将不会显示,但会在IE7和IE7模式下显示(所有这些仅适用于文档的古怪模式)模式)。 The following HTML sample demonstrates the problem (the text "Inside Table" does not display in IE8 browser mode): 下面的HTML示例演示了该问题(文本“ Inside Table”在IE8浏览器模式下不显示):

<html>
    <head>
        <title>DOCTYPE Browser mode test</title>
    </head>
    <body>
        <div id="content">Original Content</div>

        <button type="button" onclick="document.getElementById('content').innerHTML = '<!DOCTYPE>Outside table <table>Inside Table</table>';">Change Content!</button>
    </body>
</html>

Unfortunately I have not found a way to get quirks mode with IE7 browser mode. 不幸的是,我还没有找到使用IE7浏览器模式的怪癖模式的方法。 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. 您可以通过执行“ document.getElementById('content')。innerHTML = document.getElementById('content')。innerHTML”之类的方法来解决此问题,因为DOCTYPE和其他无关的内容已被解析,因此将其重置会导致表格再次显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM