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月.
scrollRestoration
は History
インターフェイスのプロパティで、ウェブアプリケーションが履歴の移動の動作で既定のスクロール位置の復元を明示的に設定できるようにします。
値
以下のうちのいずれかです。
例
>現在のスクロール復元の動作を問い合わせる
js
const scrollRestoration = history.scrollRestoration;
if (scrollRestoration === "manual") {
console.log(
"ページ上の位置は復元されないので、ユーザーが手動でスクロールする必要があります。",
);
}
自動的にページ上の位置の復元をしないようにする
js
if (history.scrollRestoration) {
history.scrollRestoration = "manual";
}
仕様書
Specification |
---|
HTML> # dom-history-scroll-restoration-dev> |
ブラウザーの互換性
Loading…