The scrollRestoration
property of History
interface allows web applications to explicitly set default scroll restoration behavior on history navigation.
Syntax
const 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 = 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
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
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
scrollRestoration | Chrome Full support 46 | Edge Full support 79 | Firefox Full support 46 | IE No support No | Opera Full support 33 | Safari Full support Yes | WebView Android No support No | Chrome Android Full support 46 | Firefox Android Full support Yes | Opera Android Full support Yes | Safari iOS Full support Yes | Samsung Internet Android Full support 5.0 |
Legend
- Full support
- Full support
- No support
- No support