EN
JavaScript - navigate back to previous page
3 points
In this article, we would like to show you how to navigate back to the previous page using JavaScript.
Quick solution:
xxxxxxxxxx
1
<button onclick="history.go(-1)">
2
Navigate to previous page
3
</button>
Note:
Using this solution you can navigate multiple pages back by specifying different number as
history.go()
argument (e.ghistory.go(-2)
- go two pages back).
In this example, we use window.history.back()
as an alternative to history.go(-1)
to go to the previous page.
xxxxxxxxxx
1
2
<html>
3
<body>
4
<button onclick="window.history.back()">
5
Navigate to previous page
6
</button>
7
</body>
8
</html>