歷史:scrollRestoration 屬性
History 介面的 scrollRestoration 屬性允許 Web 應用程式在歷史導航時顯式設定預設的滾動恢復行為。
值
以下之一:
示例
查詢當前的滾動恢復行為
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
history.scrollRestoration = "manual";
規範
| 規範 |
|---|
| HTML # dom-history-scroll-restoration-dev |
瀏覽器相容性
載入中…