JavaScript History
In this tutorial, you will learn how to access the browser’s session history by using the JavaScript history object.
The history object contains the URLs visited by the user (in the browser window).
The history object is a property of the window object.
The history object is accessed with:
window.history or just history
Example:
Try It
let length = window.history.length; or let length = history.length;
History Object Properties and Methods
back() - Loads the previous URL (page) in the history list
forward() - Loads the next URL (page) in the history list
go() - Loads a specific URL (page) from the history list
length - Returns the number of URLs (pages) in the history list