History - Go Previous Page

Back function to go to previous web page


Methods or Function: back()

back() function is used to go back to the previous web page in the history list. This does the same function as of back button in the browser window.
Code: history.back();


To create a back button that takes to the previous page when users click on it.
<script language="javascript">
function goback(){
<input type=button value="go back" onClick=goback()>


In the above example
a) we created a button
b) added an onClick event listener to the button.
c) when user click on the button the javascript function goback() will be invoked.
d) in that function we call history.back().

Ask Questions

Ask Question