Bug 9248 - Quirksmode: document.documentElement.scrollTop is always 0
: Quirksmode: document.documentElement.scrollTop is always 0
Status: RESOLVED DUPLICATE of bug 106133
Product: WebKit
Classification: Unclassified
Component: HTML DOM
: 420+
: All Mac OS X 10.4
: P2 Normal
Assigned To: Antonio Gomes
http://www.quirksmode.org/bugreports/...
:
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:


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 Adele Peterson 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."
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!

http://www.google.com/search?client=safari&rls=en&q=site:quirksmode.org+Omry+Yadan&ie=UTF-8&oe=UTF-8

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"?>
<!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 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]
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 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.

http://maisqi.com/outros/bugs/chrome/CHN6

File bug 106133.