The History allows manipulation of the browser session history, that is the pages visited in the tab or frame that the current page is loaded in. History object accessible via window.history or variable history.


property description
length The number of elements in the session history, including the currently loaded page. For a page loaded in a new tab this property equal 1.
state Any value that represents 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.


method description
back() Moves one page back in the session history. If there is no previous page, this method call does nothing. It has the same effect as calling history.go(-1).
forward() Moves forward one page in the session history. It has the same effect as calling history.go(1).
go(delta) Loads a specific page from the session history. You can use it to move forwards and backwards through the history depending on the value of the delta parameter.
Adds a state to the browser's session history stack.
  • state - the state object is a JavaScript object which is associated with the new history entry created by pushState(). Whenever the user navigates to the new state, a popstate event is fired, and the state property of the event contains a copy of the history entry's state object.
  • title - most browsers currently ignores this parameter
  • url - the new history entry's URL is given by this parameter. The browser won't attempt to load this URL after a call to pushState(), but it might attempt to load the URL later, for instance after the user restarts the browser.