History: scrollRestoration property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

The scrollRestoration property of the History interface allows web applications to explicitly set default scroll restoration behavior on history navigation.

Value

One of the following:

auto

The location on the page to which the user has scrolled will be restored.

manual

The location on the page is not restored. The user will have to scroll to the location manually.

Examples

Query the current scroll restoration behavior

js
const scrollRestoration = history.scrollRestoration;
if (scrollRestoration === "manual") {
  console.log(
    "The location on the page is not restored, user will need to scroll manually.",
  );
}

Prevent automatic page location restoration

js
if (history.scrollRestoration) {
  history.scrollRestoration = "manual";
}

Specifications

Specification
HTML
# dom-history-scroll-restoration-dev

Browser compatibility

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
scrollRestoration

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support