dom / latest / history / scrollrestoration.html /

History.scrollRestoration

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

Value

One of the followings:

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.

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

if (history.scrollRestoration) {
  history.scrollRestoration = 'manual';
}

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari WebView Android Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet
scrollRestoration
46
79
46
No
33
11
46
46
46
33
11
5.0

© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/History/scrollRestoration