views:

198

answers:

3

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?

+1  A: 

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.

Michael Madsen
@Michael Thanks for your response. Both IE8 and IE7 browser modes both treat the document as "Quirks Mode." However, the problem is that they *are* working differently.
Ben McCormack
@Ben: Then you should start by reviewing any version checking logic you have in scripts, both on the server and on the client. I don't expect jQuery to be the problem, but if you use any other scripts or frameworks, especially if they have not been updated recently, then one of them is most likely treating IE7 differently than IE8, and that this causes the problem. This applies to *any* bug that goes away by just changing the browser mode, but having the same rendering mode: it is practically guaranteed to be a version check gone wrong.
Michael Madsen
+1  A: 

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.

ZippyV
A: 

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.

jrduncans