views:

117

answers:

2

In this particular situation, I do not have a choice about the DOCTYPE. I cannot use one. It's a weird situation, but it is what it is.

We have some CSS which uses child selectors ("p > a > span", etc.). These worked in IE7, even though we didn't have a DOCTYPE...and then they suddenly stopped working. Something we did caused IE7 to go into quirks mode, and I don't know what that thing was.

I did this:

alert(document.compatMode);

And it came back with "BackCompat," so I know we're in quirks mode, which would make sense because we don't have a DOCTYPE. But we haven't had a DOCTYPE all along, and this was working, which tells me there's some other way to get IE7 out of quirks mode.

A: 

hmm maybe this will help?

There are currently two ways of declaring the ISO value in HTML files. One of them is to place the XML prolog on to the very top line of each HTML file, directly before the doctype declaration. Declaring it this way means that the first three lines of each HTML file might look like this:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;

(The first line is the XML prolog; the second and third lines are the doctype declaration.)

By not having the doctype declaration on line 1, Internet Explorer 6 reverts to quirks mode (despite the fact that the above HTML code is perfectly valid). Internet Explorer 7 however will not revert to quirks mode, and will instead render the web page in standards mode. (You may wish to read more about quirks and strict modes, if you haven't heard of these terms before.)

from: http://www.webcredible.co.uk/user-friendly-resources/css/internet-explorer-7.shtml

corroded
No, my problem is that we're integrating with a third-party system, and the only way we can inject code into the page is through Javascript "document.write." So I can't affect anything in the outer page, and they don't use a DOCTYPE. There's no way for me to affect anything outside the HTML I'm dropping into a specific DIV.
Deane
hmm thats weird, it shouldn't revert into quirks mode if that's the case. since there's no doctype. maybe you should backtrack on your latest changes to trigger that
corroded
+1  A: 

You can force IE7 compatibility mode without using a DOCTYPE by setting the X-UA-Compatible header to IE=EmulateIE7 in your web-server and sending this as part of the HTTP headers. See Configuring Web Servers to Specify Default Compatibility Modes for how to do this in IIS or Apache httpd configuration for IE7 standard mode rendering in IE8 for Apache.

Dan Diplo