In this tutorial, we will learn how to make browser to go back to previous page using JavaScript.
History back() Method
In JavaScript, the history.back()
method is used to simulate a back button click in the browser. It is a part of the window.history
object, which represents the browsing history of the window.
When you call history.back()
, it has the same effect as if the user clicked the back button on their browser. It navigates to the previous page in the session history.
Here's an example of how you can use history.back()
in JavaScript:
// Go back one step in the browsing history
history.back();
You can use this method in response to a user action or as part of your application's logic to control navigation. Its behavior may vary depending on the browser and the user's browsing history.