[Webkit-unassigned] [Bug 51899] New: Scroll history takes precedence over window.scrollTo

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Jan 4 14:41:39 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=51899

           Summary: Scroll history takes precedence over window.scrollTo
           Product: WebKit
           Version: 528+ (Nightly build)
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: UNCONFIRMED
          Severity: Normal
          Priority: P2
         Component: Page Loading
        AssignedTo: webkit-unassigned at lists.webkit.org
        ReportedBy: yohann at fb.com


Facebook needs to be able to set the scroll location onload of a page.

Unfortunately, webkit restores the scroll location for a reloaded page even if it was previously set by a javascript call.

It seems that this restore happens after the onload event is fired, making it hard to override without a setTimeout deferring a scrollTo after a totally arbitrary interval.

Acceptable solutions would be either not to restore the position if it was already set by the JS code, either to restore the position before the onload event is triggered.

To reproduce on webkit nightly, Safari or Chrome, use the following code, load the page, it should scroll to 500px. Scroll to the top, click the refresh button. 
The logs will show that an onscroll event was first triggered when the page scrolled to 500, then a second one was triggered when the browser restored the position to 0.


<html>
  <body>
    <script>
      window.onload=function() {
        window.scrollTo(0, 500);
      };

      document.onscroll=function() {
        console.log('scroll', document.body.scrollTop); 
      };
    </script>
    <div style="height:10000px">test</div>
  </body>
</html>

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list