JavaScript Window History
The window.history object contains the browser's history.
Window History
window.historyThe object can be written without the window prefix.
In order to protect user privacy, JavaScript’s method of accessing this object is restricted.
Some methods:
history.back() - Same as clicking the back button in the browser
history.forward () - Same as clicking the button forward in the browser
Window History Back
history.back() method loads the previous one in the history list URL.
This is the same as clicking the back button in a browser:
Example
<html> <head> <script> function goBack() { window.history.back() } </script> </head> <body> <input type="button" value="Back" onclick="goBack()"> </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance
Window History Forward
The history forward() method loads the next URL in the history list.
This is the same as clicking the forward button in the browser:
Example
<html> <head> <script> function goForward() { window.history.forward() } </script> </head> <body> <input type="button" value="Forward" onclick="goForward()"> </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance