The scrollRestoration
property of History
interface allows web applications to explicitly set default scroll restoration behavior on history navigation.
On this page
History: scrollRestoration property
Value
One of the following:
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 Standard # dom-history-scroll-restoration-dev |
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–2023 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