The History Object

The history object represents the user's navigation history. The history object is a property of window. Each browser window, tab, and frame has its own history object.

It's not possible to determine the visted URLs. It is possible to navigate backwards and forwards.

The following table lists the properties and methods in history object.

NameDescriptionReturns
back()Goes one step back.void
forward()Goes one step forward.void
go(<index>) Goes to a position relative to the current document. Positive values are forward, negative are backward.void
lengthReturns the number of items in the history.number
pushState(<state>, <title>, <url>) Adds an entry to the browser history.void
replaceState(<state>, <title>, <url>) Replaces the current entry in the browser history.void
stateReturns the state data associated with the current document in the browser history.object
Home 
  JavaScript Book 
    DOM  

History:
  1. The History Object
  2. history.back()
  3. history.forward()
  4. history.go(url/number)
  5. history.length
  6. history.pushState:Adding an Entry to the Browser History