1 min read
The Web History API provides easy methods to access the windows.history object. The window.history object contains the URLs (Web Sites) visited by the user.
The Web History API provides easy methods to access the windows.history object.
The window.history object contains the URLs (Web Sites) visited by the user.
The Web History API is supported in all browsers:
The back() method loads the previous URL in the windows.history list.
It is the same as clicking the “back arrow” in your browser.
<button onclick="myFunction()">Go Back</button> <script> function myFunction() { window.history.back(); } </script>
The go() method loads a specific URL from the history list:
<button onclick="myFunction()">Go Back 2 Pages</button> <script> function myFunction() { window.history.go(-2); } </script>
Powered by BetterDocs
You must be logged in to post a comment.