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 July 2015.
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 |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
scrollRestoration |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.