RE: [cssom-view] Why is body's offsetParent null ?

> So the behavioural difference between body and other elements is
> introduced because of MSIE but the Web is full of the following
> script:
> 
> var t = 0;
> var p = myElement;
> while (p) {
>    t += p.offsetTop;
>    p =  p.offsetParent;
> }
> // use t

When you want to find the offset all the way up to the top then
actually both IE and CSSOM gets it right. I made a comparison table
here a while ago:
http://www.nabble.com/RE%3A--cssom-view--small-update-p16061295.html

Though, the CSSOM scheme will break down if you want to know the 
offset to the body element as there is no way to get at this 
information.

In particular, as Garrett pointed out, this offset is available in all
browsers except Opera (and CSSOM) when using position:relative on the 
body element:
http://www.nabble.com/Re%3A--cssom-view--small-update-p16063070.html

> Because of the change you introduce saying document.body.offsetTop
> is now always zero

This is actually part of a long discussion Garrett/dhtmlkitchen and I 
have had with Anne about the suggested offset* algorithm.
You can find parts of it here:
http://www.nabble.com/-cssom-view--New-WD-%22CSSOM-View-Module%22-td15679118
html
http://www.nabble.com/-cssom-view--small-update-td15872317.html
http://www.nabble.com/Re%3A--cssom-view--small-update-td16589829.html

Best regards
Mike Wilson

Received on Wednesday, 23 April 2008 10:29:19 UTC