Object History in JavaScript. Browser history management. Co... open

Object History in JavaScript. Browser history management. Code examples

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators
Tested: ES6

The History object is designed to store the history of web page visits in the browser. This object is available to us through the object Window.

All information about the visit of the user is stored in a special stack (history stack). Using the length property, you can find out how many web pages are stored on the stack:

    document.write(window.history.length);

To move through the pages in history, the history object defines back() (move to the last viewed page) and forward() (move to the next viewed page) methods.

    history.back(); // moving back
    history.forward();//move to next viewed page

The go() method allows you to move forward and backward through history by a certain number of pages:

    history.go(-2);// let's move 2 pages back
    history.go(2);//let's move 2 pages forward
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation