Provides access to the browser's session history through the history
global object.
It exposes useful methods and properties that let you navigate back and forth through the user's history, and manipulate the contents of the history stack.
The back
and forward
methods work exactly like the Back
and Forward
buttons on browser toolbar GUI.
history.back(); history.forward();
You can jump to any part of the history with go()
method.
history.go(-1); // same as back history.go(1); // same as forward
You can refresh the page with 0
or no arguments passed to go()
method:
history.go(); // refersh current page history.go(0);
Viewing number of pages in the history stack:
const numberOfEntries = history.length;