The JavaScript history object represents an array of URLs visited by the user. By using this object, you can load previous, forward or any particular page.
The history object is the window property, so it can be accessed by:
Or,
There are only 1 property of history object.
No. | Property | Description |
---|---|---|
1 | length | returns the length of the history URLs. |
There are only 3 methods of history object.
No. | Method | Description |
---|---|---|
1 | forward() | loads the next page. |
2 | back() | loads the previous page. |
3 | go() | loads the given page number. |
Let’s see the different usage of history object.