Value

One of the following:

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

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
Product help
  • Instance properties
    1. back()
    2. replaceState()
  • Related pages for History API
    1. Window.history
  • ","source":{"folder":"en-us/web/api/history/scrollrestoration","github_url":"https://github.com/mdn/content/blob/main/files/en-us/web/api/history/scrollrestoration/index.md","last_commit_url":"https://github.com/mdn/content/commit/b8eb6acf2fa8e54254b1165e58adbe2378591da1","filename":"index.md"},"summary":"The scrollRestoration property of the History\ninterface allows web applications to explicitly set default scroll restoration behavior\non history navigation.","title":"History: scrollRestoration property","toc":[{"text":"Value","id":"value"},{"text":"Examples","id":"examples"},{"text":"Specifications","id":"specifications"},{"text":"Browser compatibility","id":"browser_compatibility"}],"baseline":{"baseline":"high","baseline_low_date":"2015-07-29","baseline_high_date":"2018-01-29","support":{"chrome":"5","chrome_android":"18","edge":"12","firefox":"4","firefox_android":"4","safari":"5","safari_ios":"4"}},"browserCompat":["api.History.scrollRestoration"],"pageType":"web-api-instance-property"}}

    Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

    Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant