--- title: History.scrollRestoration slug: Web/API/History/scrollRestoration tags: - API - HTML DOM - History API - Property - Reference translation_of: Web/API/History/scrollRestoration ---
{{APIRef("HTML DOM")}}

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

구문

let scrollRestore = history.scrollRestoration;

"auto"
페이지 내에서 사용자의 스크롤이 위치했던 장소로 복원합니다.
"manual"
스크롤을 복원하지 않습니다. 사용자가 직접 스크롤해야 합니다.

예제

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

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

스크롤 복원 비활성화

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

명세

Specification Status Comment
{{SpecName("HTML WHATWG", " #scroll-restoration-mode", "History.scrollRestoration")}} {{Spec2("HTML WHATWG")}} No change from {{SpecName("HTML5 W3C")}}.
{{SpecName("HTML5 W3C", "browsers.html#dom-history-scrollrestoration", "History.scrollRestoration")}} {{Spec2("HTML5 W3C")}} Initial definition.

브라우저 호환성

{{Compat("api.History.scrollRestoration")}}