历史
interface allows manipulation of the browser
会话历史
, that is the pages visited in the tab or frame that the current page is loaded in.
历史
interface doesn't inherit any property.
length
只读
整数
representing the number of elements in the session history, including the currently loaded page. For example, for a page loaded in a new tab this property returns
1
.
scrollRestoration
auto
or
manual
.
state
只读
any
value representing the state at the top of the history stack. This is a way to look at the state without having to wait for a
popstate
事件。
历史
interface doesn't inherit any methods.
back()
history.go(-1)
.
Calling this method to go back beyond the first page in the session history has no effect and doesn't raise an exception.
forward()
history.go(1)
.
Calling this method to go forward beyond the most recent page in the session history has no effect and doesn't raise an exception.
go()
-1
for the previous page or
1
for the next page. If you specify an out-of-bounds value (for instance, specifying
-1
when there are no previously-visited pages in the session history), this method silently has no effect. Calling
go()
without parameters or a value of
0
reloads the current page. Internet Explorer lets you specify a string, instead of an integer, to go to a specific URL in the history list.
pushState()
replaceState()
| 规范 | 状态 | 注释 |
|---|---|---|
|
HTML 实时标准
The definition of 'History' in that specification. |
实时标准 |
添加
scrollRestoration
属性。
|
|
HTML5
The definition of 'History' in that specification. |
推荐 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
历史
|
Chrome 1 | Edge 12 | Firefox 1 | IE 10 | Opera 3 | Safari 1 | WebView Android 1 | Chrome Android 18 | Firefox Android 4 | Opera Android 10.1 | Safari iOS 1 | Samsung Internet Android 1.0 |
back
|
Chrome Yes | Edge 12 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
forward
|
Chrome Yes | Edge 12 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
go
|
Chrome Yes | Edge 12 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
length
|
Chrome Yes | Edge 12 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
pushState
|
Chrome 5 | Edge 12 |
Firefox
4
|
IE 10 | Opera 11.5 | Safari 5 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
4
|
Opera Android 11.5 | Safari iOS 4.3 | Samsung Internet Android 1.0 |
replaceState
|
Chrome 5 | Edge 12 |
Firefox
4
|
IE 10 | Opera 11.5 | Safari 5 | WebView Android ≤37 | Chrome Android 18 |
Firefox Android
4
|
Opera Android 11.5 | Safari iOS 4.3 | Samsung Internet Android 1.0 |
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 |
state
|
Chrome Yes | Edge 12 | Firefox Yes | IE 10 | Opera Yes | Safari Yes | WebView Android Yes | Chrome Android Yes | Firefox Android Yes | Opera Android Yes | Safari iOS Yes | Samsung Internet Android Yes |
完整支持
不支持
见实现注意事项。
Window.history
property returning the history of the current session.