
Some parts of this message have been removed.
Learn more about Nabble's
security policy.
See
http://dev.w3.org/csswg/cssom-view/Currently it does not define any special handling for the root element and HTML <body> element. However, all browsers implement some special handling for these elements, to give access to the viewport scrollbar state.
I've only tested getting and setting scrollTop in HTML. Standards-mode and quirks-mode testcases attached. Here are the results:
IE8, Firefox (trunk, and many previous versions, I think):
In standards mode, setting scrollTop on the <html> element scrolls the viewport, and reading it gives the current viewport scroll position. Getting scrollTop on <body> always returns 0 and setting it does nothing.
In quirks mode, setting scrollTop on the <body> element scrolls the viewport, and
reading it gives the current viewport scroll position. Getting scrollTop
on <html> always returns 0 and setting it does nothing.
Safari 4:
In both standards mode and quirks mode, setting scrollTop on the <body> element scrolls
the viewport, and
reading it gives the current viewport scroll position. Getting scrollTop
on <html> always returns 0 and setting it does nothing.
Opera 10:
In standards mode, setting scrollTop on the <html> OR <body> element scrolls
the viewport. Getting scrollTop on <html> gives the current viewport scroll
position. Getting scrollTop on <body> always returns 0.
In standards mode, setting scrollTop on the <html> OR <body>
element scrolls
the viewport. Getting scrollTop on <body> gives the current
viewport scroll
position. Getting scrollTop on <html> always returns 0.
I suggest that the IE8/Firefox behaviour be written into the spec. I think that scrollTop on the root element should work even for non <html> roots and non-HTML documents, although we don't currently implement this.
I'm not sure what to do about scrollWidth and scrollHeight; looking at the code they will behave similarly to scrollTop in Firefox --- returning values from the viewport, instead of the element --- but I haven't tested them.
Rob
--
"He was pierced for our transgressions, he was crushed for our iniquities; the punishment that brought us peace was upon him, and by his wounds we are healed. We all, like sheep, have gone astray, each of us has turned to his own way; and the LORD has laid on him the iniquity of us all." [Isaiah 53:5-6]