What is the use of history object?
The history object can be used to access all the URLs that are visited by the user within the browser window. It can be written without the window prefix.
- history.length – returns the number of URLs in the history list of the current browser window.
- history.back() – same as clicking back in the browser. It loads the previous URL in the history list.
- history.forward() – same as clicking forward in the browser. It loads the next URL in the history list.
- history.go() – same as entering a specific URL. It loads a specific URL from the history list.