开发者

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.

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开发者_StackOverflow中文版 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?


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 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.


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):

<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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜