历史: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 |
浏览器兼容性
加载中…