Home Javascript Go back to previous page with help of php or javascript

Go back to previous page with help of php or javascript

by therichpost
0 comments
Javascript Array methods cheat sheet part - 1

Hello to all, welcome to therichpost.com. In this post, i will tell you, how to Go back previous page with help of php or javascript?

Php and Javascript both are very famous and top languages.

Here is working for Go back to previous page with help of php or javascript:
//JavaScript
<input type="button" value="Go Back From Whence You Came!" onclick="history.back(-1)" />

//or
<button onclick="goBack()">Go Back</button>
<script>
function goBack() {
    window.history.back();
}
</script>

//PHP
<?php
  $url = htmlspecialchars($_SERVER['HTTP_REFERER']);
  echo "<a href='$url'>back</a>"; 
?>

//or

<?php header('Location: ' . $_SERVER['HTTP_REFERER']); ?>

 There are so many tricks in php and javascript and i will let you know all. Please do comment if you any query related            to this post. Thank you. Therichpost.com.

You may also like

Leave a Comment

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