scrollRestoration
property of
历史
interface allows web applications to explicitly set default scroll restoration behavior on history navigation.
const scrollRestore = history.scrollRestoration
auto
The location on the page to which the user has scrolled will be restored.
manual
The location on the page is not restored. The user will have to scroll to the location manually.
const scrollRestoration = history.scrollRestoration
if (scrollRestoration === 'manual') {
console.log('The location on the page is not restored, user will need to scroll manually.');
}
if (history.scrollRestoration) {
history.scrollRestoration = 'manual';
}
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'scroll restoration mode' in that specification. |
实时标准 | 无变化自 HTML5 . |
|
HTML5
The definition of 'History.scrollRestoration' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
scrollRestoration
|
Chrome 46 | Edge 79 | Firefox 46 | IE No | Opera 33 | Safari Yes | WebView Android No | Chrome Android 46 | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android 5.0 |
完整支持
不支持