Javascript – Return to Previous URL

The following Javascript function will redirect you to the previous URL when it is called.

function goToPreviousPage() {
  history.go(-1)
}

 

Add a return button to your HTML page as follow.

<input type="button" name="returnButton" value="Return" onclick="history.go(-1);"/>

 

Done =)

Reference: Back to previous page

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.