History.scrollRestoration

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

Syntax

let scrollRestore = history.scrollRestoration;

Values

"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 = window.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 (window && window.history && window.history.scrollRestoration) {
  window.history.scrollRestoration = 'manual';
}

Specifications

Specification Status Comment
HTML Living Standard
The definition of 'scroll restoration mode' in that specification.
Living Standard No change from HTML5.
HTML5
The definition of 'History.scrollRestoration' in that specification.
Recommendation Initial definition.

Browser Compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
scrollRestorationChrome Full support 46Edge No support NoFirefox Full support 46IE No support NoOpera Full support 33Safari Full support YesWebView Android No support NoChrome Android Full support 46Firefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown