Bug 9248 - Quirksmode: document.documentElement.scrollTop is always 0
Summary: Quirksmode: document.documentElement.scrollTop is always 0
Status: RESOLVED DUPLICATE of bug 106133
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: 420+
Hardware: All OS X 10.4
: P2 Normal
Assignee: Antonio Gomes
URL: http://www.quirksmode.org/bugreports/...
: 16911 (view as bug list)
Depends on:
Blocks: 9610
  Show dependency treegraph
Reported: 2006-06-02 12:02 PDT by Adele Peterson
Modified: 2013-09-25 21:06 PDT (History)
16 users (show)

See Also:

Testcase (1.12 KB, text/html)
2010-11-17 02:33 PST, João Eiras
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Adele Peterson 2006-06-02 12:02:06 PDT

"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."
Comment 1 Joost de Valk (AlthA) 2006-06-24 13:27:32 PDT
Changing component, confirming this is still a bug.
Comment 2 Joost de Valk (AlthA) 2006-06-24 13:27:50 PDT
Changing component, confirming this is still a bug.
Comment 3 Alexey Proskuryakov 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.
Comment 4 David Kilzer (:ddkilzer) 2007-02-12 06:44:07 PST
Google to the rescue!


Comment 5 Dave Hyatt 2007-02-12 14:09:14 PST
I fixed this in our new list boxes, although it's still not perfect.
Comment 6 Robert Blaut 2008-02-13 03:06:08 PST
Is the bug still alive? Test page was gone. A new test case uploaded would be welcome.
Comment 7 John Russell 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 
Comment 8 John Russell 2008-05-20 07:32:41 PDT
here is the shortened test
<?xml version="1.1" encoding="iso-8859-1"?>
<html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<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
  document.getElementById('stickyEl').style.top =
  setTimeout(checkScrolled2,scrollSpeed2) ;}
function stickyInit(){
  copy='<a href="jstutor5.htm">GoTo Top<\/a>'; //dynamic text only
  document.getElementById('stickyEl').innerHTML=copy; //dynamic text only
<body onload="stickyInit();"><h1>StickyBug:VE3LL@RAC.CA</h1>
<div id="stickyEl"

// 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





function stickyInit(){    //write link dynamically




Comment 9 Robert Blaut 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.
Comment 10 Robert Blaut 2008-07-23 13:21:40 PDT
*** Bug 16911 has been marked as a duplicate of this bug. ***
Comment 11 Peter Potrowl 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)...
Comment 12 johnnyding 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.
Comment 13 João Eiras 2010-11-17 02:33:01 PST
Created attachment 74095 [details]

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.
Comment 14 Antonio Gomes 2013-09-25 13:15:23 PDT

*** This bug has been marked as a duplicate of bug 106133 ***
Comment 15 Antonio Gomes 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.


File bug 106133.