HTML CSS Bootstrap Javascript Icons Python
JavaScript Reference
JS Reference
JS Array Object JS Boolean Object JS Date Object JS Style Declaration Object JS Error Object JS Global Object JS Math Object JS Number Object JS String Object JS RegExp Object JS Statements
DOM Reference
DOM Attribute DOM Console DOM Document DOM Element DOM Events DOM Event Objects DOM History DOM HTMLCollection DOM Location DOM Navigator DOM Screen DOM Style DOM Window WEB Storage

JavaScript History Object

The History Object

The history object contains the URLs visited by the user.

The history object is part of the window object and can be written without the window prefix.

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

To protect the privacy of the users, there are limitations to how JavaScript can access this object.

History Object Properties

The following table lists the properties of the History object:

Property Description
length Returns the number of URLs in the history list, including the currently loaded page

History Object Methods

The following table lists the methods of the History object:

Method Description
back() Goes to the previous page in session history, the same action as when the user clicks the browser's Back button
forward() Goes to the next page in session history, the same action as when the user clicks the browser's Forward button
go() 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