RESOLVED DUPLICATE of bug 106133 9248
Quirksmode: document.documentElement.scrollTop is always 0
https://bugs.webkit.org/show_bug.cgi?id=9248
Summary Quirksmode: document.documentElement.scrollTop is always 0
Adele Peterson
Reported 2006-06-02 12:02:06 PDT
http://www.quirksmode.org/bugreports/archives/safari/index.html "It is not possible to obtain the correct scrollTop value of a select list in Explorer, regardless of strict/quirks mode. to reproduce, enter the test page, scroll the list a bit, then hit the button. The alert will display 0 value in IE, and correct value in Mozilla based browsers. Test page http://firefang.net/~omry/bug/scrollTop.html Workaround is not included Reported by: Omry Yadan."
Attachments
Testcase (1.12 KB, text/html)
2010-11-17 02:33 PST, João Eiras
no flags
Joost de Valk (AlthA)
Comment 1 2006-06-24 13:27:32 PDT
Changing component, confirming this is still a bug.
Joost de Valk (AlthA)
Comment 2 2006-06-24 13:27:50 PDT
Changing component, confirming this is still a bug.
Alexey Proskuryakov
Comment 3 2007-02-12 03:37:17 PST
The test page is 404, and I cannot find the report on quirksmode.org. In my testing, I'm getting 0 from Firefox, too, so I am not sure what the original test could be.
David Kilzer (:ddkilzer)
Comment 4 2007-02-12 06:44:07 PST
Dave Hyatt
Comment 5 2007-02-12 14:09:14 PST
I fixed this in our new list boxes, although it's still not perfect.
Robert Blaut
Comment 6 2008-02-13 03:06:08 PST
Is the bug still alive? Test page was gone. A new test case uploaded would be welcome.
John Russell
Comment 7 2008-05-20 07:23:26 PDT
I am finding that document.documentElement.scrollTop still gives zero for WebKit nightly downloaded on May 19, 2008. msie, firefox, opera reporting correct numbers. My test case is rather long but i will reduce it to a couple of thou bytes and then share if you wish .... john in niagara canada
John Russell
Comment 8 2008-05-20 07:32:41 PDT
here is the shortened test <?xml version="1.1" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head><title>StickyBug:VE3LL@RAC.CA</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/> <script type="text/javascript">//<![CDATA[ var ltop2;scrollSpeed2=20; //Screen refresh rate in msec. function checkScrolled2(){ //backTo Top link stays in lower right window.status=document.documentElement.scrollTop document.getElementById('stickyEl').style.top = document.documentElement.scrollTop+ltop2+'px'; setTimeout(checkScrolled2,scrollSpeed2) ;} function stickyInit(){ copy='<a href="jstutor5.htm">GoTo Top<\/a>'; //dynamic text only document.getElementById('stickyEl').innerHTML=copy; //dynamic text only ltop2=parseInt(document.getElementById('stickyEl').style.top,10); checkScrolled2();} //]]> </script></head> <body onload="stickyInit();"><h1>StickyBug:VE3LL@RAC.CA</h1> <div id="stickyEl" style="position:absolute;top:380px;left:655px;z-index:3">***</div> <pre> // SOME STUFF TO ALLOW SCREEN TO SCROLL -- WATCH THE GoToTop MARKER // and then the status line for what scrollTop is returning // repeat with MSIE, FireFox and Opera /* checked with jsLint 2008 04 22 */ // scripts for tutorial #5 - DOM and DHTML /* BackToTop link that sticks in one spot */ var ltop2;scrollSpeed2=20; //Screen refresh rate in msec.? function checkScrolled2(){ //backTo Top link stays in lower right window.status=document.documentElement.scrollTop document.getElementById('stickyEl').style.top= document.documentElement.scrollTop+ltop2+'px'; setTimeout(checkScrolled2,scrollSpeed2);} function stickyInit(){ //write link dynamically document.getElementById('stickyEl').innerHTML=copy; ltop2=parseInt(document.getElementById('stickyEl').style.top,10); checkScrolled2();} </pre></body></html>
Robert Blaut
Comment 9 2008-07-23 13:20:45 PDT
Nice demo how browsers deal with scrollTop is available on http://13thparallel.com/archive/viewport/example6.htm You can notice that in WebKit only working property is document.body.scrollTop and it works in quirks mode and strict mode. Only document.documentElement.scrollTop is unsupported.
Robert Blaut
Comment 10 2008-07-23 13:21:40 PDT
*** Bug 16911 has been marked as a duplicate of this bug. ***
Peter Potrowl
Comment 11 2009-09-23 03:38:28 PDT
At this date, the bug is still here, and it is not Mac-specific (same problem with Google Chrome and Konqueror when using Webkit)...
johnnyding
Comment 12 2009-10-21 00:22:57 PDT
Now IE6/7/8 and Firefox get scrollTop from document.documentElement.scrollTop under standards mode and from document.body.scrollTop under quirks mode. But all WebKit based browsers (like Safari and Chrome), under both standards and quirks mode, all only get scrollTop from document.body.scrollTop, and document.documentElement.scrollTop is always 0. Since there is no standard/universal way to get scrollTop, How about to get scrollTop by : document.documentElement.scrollTop >= document.body.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop. scrollLeft is similar as scrollTop.
João Eiras
Comment 13 2010-11-17 02:33:01 PST
Created attachment 74095 [details] Testcase My testcase tests standards mode and shows that in webkit, documentElement.scrollTop/Left are 0. However, scrollLeft and scrollTop on the document element should returns the amount of viewport scrolled in that direction, while the same properties on body must be zero (unless the body also overflows, which is not the case in the testcase). Known victim: http://www.is-real.net/experiments/css3/wonder-webkit/ Site relies on this behavior and breaks in all the other browser, although the others implement the *correct* behavior.
Antonio Gomes
Comment 14 2013-09-25 13:15:23 PDT
*** This bug has been marked as a duplicate of bug 106133 ***
Antonio Gomes
Comment 15 2013-09-25 21:06:43 PDT
(In reply to comment #14) > > *** This bug has been marked as a duplicate of bug 106133 *** bug 106133 fixed the problem that WebKit had handling scrollTop/Left for document.documentElement and document.body in quirks and strict modes. Setters of these properties do not work still, so the URL below still. Fails. http://maisqi.com/outros/bugs/chrome/CHN6 File bug 106133.
Note You need to log in before you can comment on or make changes to this bug.