The History
interface allows manipulation of the browser session history, that is the pages visited in the tab or frame that the current page is loaded in.
The History
interface doesn't inherit any property.
History.length
Read only
Integer
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
.History.current
Read only Obsolete since Gecko 26
DOMString
representing the URL of the active item of the session history. This property was never available to web content and is no more supported by any browser. Use Location.href
instead.History.next
Read only Obsolete since Gecko 26
DOMString
representing the URL of the next item in the session history. This property was never available to web content and is not supported by other browsers.History.previous
Read only Obsolete since Gecko 26
DOMString
representing the URL of the previous item in the session history. This property was never available to web content and is not supported by other browsers.History.scrollRestoration
auto
or manual
.History.state
Read only 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
event.The History
interface doesn't inherit any methods.
History.back()
history.go(-1)
. History.forward()
history.go(1)
. History.go()
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.History.pushState()
History.replaceState()
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'History' in that specification. | Living Standard | Adds the scrollRestoration attribute. |
HTML5 The definition of 'History' in that specification. | Recommendation | Initial definition. |
Custom Scroll Restoration - History-based API The definition of 'History' in that specification. | Draft | Adds the scrollRestoration attribute. |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes |
back |
Yes | ? | Yes | ? | ? | ? |
forward |
Yes | ? | Yes | ? | ? | ? |
go |
Yes | ? | Yes | ? | ? | ? |
length |
Yes | ? | Yes | ? | ? | ? |
pushState |
5 | Yes | 4
|
10 | 11.5 | 5 |
replaceState |
5 | Yes | 4
|
10 | 11.5 | 5 |
scrollRestoration |
46 | No | 46 | No | 33 | Yes |
state |
Yes | ? | Yes | ? | ? | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | ? |
back |
Yes | Yes | ? | Yes | ? | ? | ? |
forward |
Yes | Yes | ? | Yes | ? | ? | ? |
go |
Yes | Yes | ? | Yes | ? | ? | ? |
length |
Yes | Yes | ? | Yes | ? | ? | ? |
pushState |
Yes | Yes | Yes | Yes | Yes | 4.3 | ? |
replaceState |
Yes | Yes | Yes | Yes | Yes | 4.3 | ? |
scrollRestoration |
No | 46 | No | Yes | Yes | Yes | ? |
state |
Yes | Yes | ? | Yes | ? | ? | ? |
Window.history
property returning the history of the current session.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/history