Verlauf: scrollRestoration-Eigenschaft
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Die scrollRestoration
-Eigenschaft des History
-Interfaces ermöglicht es Webanwendungen, das standardmäßige Verhalten zur Wiederherstellung des Scrollens bei der Verlaufsnavigation explizit festzulegen.
Wert
Beispiele
Aktuelles Verhalten der Scroll-Wiederherstellung abfragen
js
const scrollRestoration = history.scrollRestoration;
if (scrollRestoration === "manual") {
console.log(
"The location on the page is not restored, user will need to scroll manually.",
);
}
Automatische Wiederherstellung der Seitenposition verhindern
js
history.scrollRestoration = "manual";
Spezifikationen
Specification |
---|
HTML # dom-history-scroll-restoration-dev |