History: thuộc tính scrollRestoration
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since January 2020.
Thuộc tính scrollRestoration của giao diện History cho phép ứng dụng web đặt rõ ràng hành vi khôi phục vị trí cuộn mặc định khi điều hướng lịch sử.
Giá trị
Một trong các giá trị sau:
Ví dụ
>Truy vấn hành vi khôi phục vị trí cuộn hiện tại
js
const scrollRestoration = history.scrollRestoration;
if (scrollRestoration === "manual") {
console.log(
"The location on the page is not restored, user will need to scroll manually.",
);
}
Ngăn việc tự động khôi phục vị trí trên trang
js
history.scrollRestoration = "manual";
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| HTML> # dom-history-scroll-restoration-dev> |