Bug 9248 - Quirksmode: document.documentElement.scrollTop is always 0
: Quirksmode: document.documentElement.scrollTop is always 0
Status: RESOLVED DUPLICATE of bug 106133
: WebKit
HTML DOM
: 420+
: All Mac OS X 10.4
: P2 Normal
Assigned To:
: http://www.quirksmode.org/bugreports/...
:
:
: 9610
  Show dependency treegraph
 
Reported: 2006-06-02 12:02 PST by
Modified: 2013-09-25 21:06 PST (History)


Attachments
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 From 2006-06-02 12:02:06 PST
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."
------- Comment #1 From 2006-06-24 13:27:32 PST -------
Changing component, confirming this is still a bug.
------- Comment #2 From 2006-06-24 13:27:50 PST -------
Changing component, confirming this is still a bug.
------- Comment #3 From 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 #5 From 2007-02-12 14:09:14 PST -------
I fixed this in our new list boxes, although it's still not perfect.
------- Comment #6 From 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 From 2008-05-20 07:23:26 PST -------
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 From 2008-05-20 07:32:41 PST -------
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>
------- Comment #9 From 2008-07-23 13:20:45 PST -------
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 From 2008-07-23 13:21:40 PST -------
*** Bug 16911 has been marked as a duplicate of this bug. ***
------- Comment #11 From 2009-09-23 03:38:28 PST -------
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 From 2009-10-21 00:22:57 PST -------
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 From 2010-11-17 02:33:01 PST -------
Created an attachment (id=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.
------- Comment #14 From 2013-09-25 13:15:23 PST -------

*** This bug has been marked as a duplicate of bug 106133 ***
------- Comment #15 From 2013-09-25 21:06:43 PST -------
(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.