Forum Moderators: not2easy

Message Too Old, No Replies

IE Expressions and!DOCTYPE

Exact opposite of problem described elsewhere.

         

Lance

9:56 pm on Aug 19, 2004 (gmt 0)

10+ Year Member



I've search high and low and have found several people have the opposite problem from mine, but I have found no solution.

I'm using IE's CSS expressions to emulate POSITION:fixed on a few elements, and it is working quite nicely. That is, until I removed my!DOCTYPE statement to test it in quirks mode. Then it blew up and acted is if the elements were just positioned absolute.

A Google search found several people have the problem of expressions working fine in quirks mode, but failing when the!DOCTYPE was applied. It didn't appear anyone ever found a resolution though, so I pose the question here.


#Measure
{
POSITION: fixed;
TOP: 0px;
LEFT: 0px;
HEIGHT: 390px;
WIDTH: 766px;
BORDER: #f00 1px solid;
}
* html body #Measure
{
POSITION: absolute;
TOP: expression(documentElement.scrollTop);
}

This bit of CSS works perfectly well in IE in compliant mode, but fails without the!DOCTYPE being declared.

Can anyone sahed some light on this for me?

Thanks,
-Lance

johnnie

12:28 am on Aug 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This may sound stupid, but why should you bother?

Quirks mode is just that, quirks mode. A browser in quirks mode has no standards (which implies: no guidelines) on how to interpret the code and will render it in it's own, quirky, way.

Expressions working in quirks mode and failing in compliant mode are wrong expressions :) Don' try to understand quirks mode, it just plain sucks ;)

If it works (preferrably chross-browser) and validates with a doctype, then don't change it.

Lance

12:38 am on Aug 20, 2004 (gmt 0)

10+ Year Member



It's that "cross browser" issue you mentioned that is the issue. If it fails in IE in quirks mode, then it also fails in IE < 6.

If you take a look at the statistics at counter.com [thecounter.com], IE 5.x is still used more than all other browsers combined with the exception of IE6.

Lance

1:36 pm on Aug 20, 2004 (gmt 0)

10+ Year Member



RESOLUTION:


* html body #Measure
{
POSITION: absolute;
TOP: expression(offsetParent.scrollTop);
}

It seems IE in compliant mode uses document.documentElement to access the <html> element as the root of the document while IE < 6 uses document.body as the root. Using offsetParent will read an object's parent regardless of what it is.

This method allows you to emulate POSITION:fixed; and it's even flicker-free.