--- title: History.scrollRestoration slug: Web/API/History/scrollRestoration tags: - API - HTML DOM - History - History API - Property - Reference translation_of: Web/API/History/scrollRestoration ---
{DOMxRef("History"))的接口——滚动恢复属性
允许web应用程序在历史导航上显式地设置默认滚动恢复行为
const 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) { history.scrollRestoration = 'manual'; }
规范 | 状态 | 评论 |
---|---|---|
{{SpecName("HTML WHATWG", "#scroll-restoration-mode", "scroll restoration mode")}} | {{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")}}