History Object
- In JavaScript, the history object provides access to the user's browsing history in the current browser window or tab.
- The history object allows you to interact with and manipulate the navigation history, enabling actions like moving backwards and forward through the user's browsing history, as well as changing the current URL without a full page reload.
Properties:
History.length:
- This property returns the number of entries in the browsing history, indicating how many pages the user has visited in the current session.
Methods:
history.back():
- This method simulates a click on the browser's "Back" button, effectively navigating to the previous page in the history.
history.forward():
- This method simulates a click on the browser's "Forward" button, moving to the next page in the history if available.
history.go([delta]):
- The go method allows you to navigate a specific number of steps in the browsing history. You can provide a positive or negative integer delta to move forward or backward in history, respectively.