This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Problem: All major browsers restore scroll position when a user traverses history. This behavior works well for document style web sites but it is often not appropriate for single-page web applications where the page content may be reconstructed (often asynchronously) upon navigation and where the application wants to control the details of visual transition between UI states. Currently it is not possible to disable the scroll behavior so web developers have resorted to various hacks. Full discussion on mailing list: https://lists.w3.org/Archives/Public/public-whatwg-archive/2015Mar/0070.html Proposed solution: We should allow web applications to explicitly disable user agents default scroll restoration behavior via History API. Here are the proposed changes to achieve this: - Add a fourth optional parameter 'options' to both history.pushState, and history.replaceState. Options default values is backward compatible. - Add a new attribute history.options that exposes the current effective value of this new property. This is also used to provide a simple feature detection mechanism to check that the user-agent supports this new optional property. Below is the IDL for the proposed changes: partial interface History { void pushState(in any data, in DOMString title, in optional DOMString url, in optional StateOptions options); void replaceState(in any data, in DOMString title, in optional DOMString url, in optional StateOptions options); readonly attribute StateOptions options; }; dictionary StateOptions { boolean willRestoreScroll = false }
Here is Blink intent-to-implement: https://groups.google.com/a/chromium.org/d/msg/blink-dev/U1e2lmGs4tM/9_70ojL8TiIJ Here is Chromium bug that tracks the implementation of this for chromium: https://code.google.com/p/chromium/issues/detail?id=477353 Note that Chromium bug describes a slightly different API which has been proposed on WhatWG mailing list. This is not an issue and we will implement the API that is accepted by specification.
Mozilla bug for addressing this issue somehow: https://bugzilla.mozilla.org/show_bug.cgi?id=679458
After several rounds of feedback from WHATWG we have update the API to use a single attribute on history object. This API is supported by Mozilla. Here is the unofficial spec which list changes to the HTML spec: http://majido.github.io/scroll-restoration-proposal/history-based-api.html Here is a set of web platform tests that verify this new attribute: http://majido.github.io/scroll-restoration-proposal/tests/ Web IDL for the new API: enum ScrollRestoration { "auto", "manual" }; partial interface History { attribute ScrollRestoration scrollRestoration; };
This API is shipping in latest chrome stable. https://www.chromestatus.com/features/5657284784947200
https://github.com/whatwg/html/pull/278