History

This translation is incomplete. Please help translate this article from English

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.

Properties

The History interface doesn't inherit any property.

length Read only
Returns an 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.
scrollRestoration
Allows web applications to explicitly set default scroll restoration behavior on history navigation. This property can be either auto or manual.
state Read only
Returns an 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.

Methods

The History interface doesn't inherit any methods.

back()
This asynchronous method goes to the previous page in session history, the same action as when the user clicks the browser's Back button. Equivalent to 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()
This asynchronous method goes to the next page in session history, the same action as when the user clicks the browser's Forward button; this is equivalent to 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()
Asynchronously loads a page from the session history, identified by its relative location to the current page, for example -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()
Pushes the given data onto the session history stack with the specified title (and, if provided, URL). The data is treated as opaque by the DOM; you may specify any JavaScript object that can be serialized.  Note that all browsers but Safari currently ignore the title parameter. For more information, see Working with the History API.
replaceState()
Updates the most recent entry on the history stack to have the specified data, title, and, if provided, URL. The data is treated as opaque by the DOM; you may specify any JavaScript object that can be serialized.  Note that all browsers but Safari currently ignore the title parameter. For more information, see Working with the History API.

Specifications

Specification Status Comment
HTML Living Standard
La definición de 'History' en esta especificación.
Living Standard Adds the scrollRestoration attribute.
HTML5
La definición de 'History' en esta especificación.
Recommendation Initial definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome para AndroidFirefox para AndroidOpera para AndroidSafari en iOSSamsung Internet
HistoryChrome Soporte completo 1Edge Soporte completo 12Firefox Soporte completo 1IE Soporte completo 10Opera Soporte completo 3Safari Soporte completo 1WebView Android Soporte completo 1Chrome Android Soporte completo 18Firefox Android Soporte completo 4Opera Android Soporte completo 10.1Safari iOS Soporte completo 1Samsung Internet Android Soporte completo 1.0
backChrome Soporte completo SiEdge Soporte completo 12Firefox Soporte completo SiIE Soporte completo 10Opera Soporte completo SiSafari Soporte completo SiWebView Android Soporte completo SiChrome Android Soporte completo SiFirefox Android Soporte completo SiOpera Android Soporte completo SiSafari iOS Soporte completo SiSamsung Internet Android Soporte completo Si
forwardChrome Soporte completo SiEdge Soporte completo 12Firefox Soporte completo SiIE Soporte completo 10Opera Soporte completo SiSafari Soporte completo SiWebView Android Soporte completo SiChrome Android Soporte completo SiFirefox Android Soporte completo SiOpera Android Soporte completo SiSafari iOS Soporte completo SiSamsung Internet Android Soporte completo Si
goChrome Soporte completo SiEdge Soporte completo 12Firefox Soporte completo SiIE Soporte completo 10Opera Soporte completo SiSafari Soporte completo SiWebView Android Soporte completo SiChrome Android Soporte completo SiFirefox Android Soporte completo SiOpera Android Soporte completo SiSafari iOS Soporte completo SiSamsung Internet Android Soporte completo Si
lengthChrome Soporte completo SiEdge Soporte completo 12Firefox Soporte completo SiIE Soporte completo 10Opera Soporte completo SiSafari Soporte completo SiWebView Android Soporte completo SiChrome Android Soporte completo SiFirefox Android Soporte completo SiOpera Android Soporte completo SiSafari iOS Soporte completo SiSamsung Internet Android Soporte completo Si
pushStateChrome Soporte completo 5Edge Soporte completo 12Firefox Soporte completo 4
Notas
Soporte completo 4
Notas
Notas Until Firefox 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.
IE Soporte completo 10Opera Soporte completo 11.5Safari Soporte completo 5WebView Android Soporte completo ≤37Chrome Android Soporte completo 18Firefox Android Soporte completo 4
Notas
Soporte completo 4
Notas
Notas Until Firefox 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.
Opera Android Soporte completo 11.5Safari iOS Soporte completo 4.3Samsung Internet Android Soporte completo 1.0
replaceStateChrome Soporte completo 5Edge Soporte completo 12Firefox Soporte completo 4
Notas
Soporte completo 4
Notas
Notas Until Firefox 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.
IE Soporte completo 10Opera Soporte completo 11.5Safari Soporte completo 5WebView Android Soporte completo ≤37Chrome Android Soporte completo 18Firefox Android Soporte completo 4
Notas
Soporte completo 4
Notas
Notas Until Firefox 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.
Opera Android Soporte completo 11.5Safari iOS Soporte completo 4.3Samsung Internet Android Soporte completo 1.0
scrollRestorationChrome Soporte completo 46Edge Soporte completo 79Firefox Soporte completo 46IE Sin soporte NoOpera Soporte completo 33Safari Soporte completo SiWebView Android Sin soporte NoChrome Android Soporte completo 46Firefox Android Soporte completo SiOpera Android Soporte completo SiSafari iOS Soporte completo SiSamsung Internet Android Soporte completo 5.0
stateChrome Soporte completo SiEdge Soporte completo 12Firefox Soporte completo SiIE Soporte completo 10Opera Soporte completo SiSafari Soporte completo SiWebView Android Soporte completo SiChrome Android Soporte completo SiFirefox Android Soporte completo SiOpera Android Soporte completo SiSafari iOS Soporte completo SiSamsung Internet Android Soporte completo Si

Leyenda

Soporte completo  
Soporte completo
Sin soporte  
Sin soporte
Ver notas de implementación.
Ver notas de implementación.

See also

  • The Window.history property returning the history of the current session.