× Introduction Setup Environment Building blocks Built-in functions Data Types Strings Operators Conditional statements Loop statements Functions Arrays Understaing Objects Date Object Number Object Math Object String Object Window Location Navigator History DOM Basics Forms
   Programs
Basic Control Loops Functions Arrays Examples Projects Quick Ref.
   Exercises
Variables Data Types Operators Decision Loops Reeborg's World



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