- From: Robert O'Callahan <robert@ocallahan.org>
- Date: Thu, 29 Oct 2009 16:31:12 +1300
- To: Anne van Kesteren <annevk@opera.com>
- Cc: www-style <www-style@w3.org>
- Message-ID: <11e306600910282031u36e6612ds20b5441831cc1018@mail.gmail.com>
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]
Attachments
- text/html attachment: test.html
- text/html attachment: test2.html
Received on Thursday, 29 October 2009 03:31:52 UTC