The History
interface allows to manipulate 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. History.pushState()
History.replaceState()
Specification | Status | Comment |
---|---|---|
WHATWG 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. | Editor's Draft | Adds the scrollRestoration attribute. |
Feature | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
pushState and replaceState
| 5.0 | (Yes) | 4.0 [1] | 10 | 11.5 | 5 |
scrollRestoration | 46.0 | No support | 46.0 (46.0) | No support | 33 | No support |
Feature | Android | Android Webview | Edge | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic support | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) | (Yes) |
pushState and replaceState
| 2.2 | (Yes) | (Yes) | (Yes) | 10 | (Yes) | 4.3 | (Yes) |
scrollRestoration | No support | 46.0 | No support | (Yes) | No support | (Yes) | No support | 46.0 |
[1] In Firefox 2 through 5, the passed object is serialized using JSON. Starting in Firefox 6, the object is serialized using the structured clone algorithm. This allows a wider variety of objects to be safely passed.
Window.history
property returning the history of the current session.
© 2005–2017 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