This page was translated from English by the community. Learn more and join the MDN Web Docs community.

View in English Always switch to English

History.scrollRestoration

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2020년 1월⁩.

History.scrollRestoration 속성을 사용하면 기록 탐색 시 사용할 스크롤 위치 복원 기능의 기본값을 웹 애플리케이션이 지정할 수 있습니다.

구문

js
let scrollRestore = history.scrollRestoration;

"auto"

페이지 내에서 사용자의 스크롤이 위치했던 장소로 복원합니다.

"manual"

스크롤을 복원하지 않습니다. 사용자가 직접 스크롤해야 합니다.

예제

현재 스크롤 복원 여부 알아내기

js
const scrollRestoration = history.scrollRestoration;
if (scrollRestoration === "manual") {
  console.log(
    "The location on the page is not restored, user will need to scroll manually.",
  );
}

스크롤 복원 비활성화

js
if (history.scrollRestoration) {
  window.history.scrollRestoration = "manual";
}

명세

Specification
HTML
# dom-history-scroll-restoration-dev

브라우저 호환성