Code Snippets Gallery
“Go Back” Button
Browsers already have “back” buttons, so you’d better have a darn good reason for needing to put one on your page!
Input button with inline JavaScript
<input type="button" value="Go Back From Whence You Came!" onclick="history.back(-1)" />
This is totally obtrusive, but you could fix that by only appending this button through JavaScript.
PHP
If JavaScript isn’t a possibility, you could use the HTTP_REFERER, sanitize it, and echo it out via PHP.
<?php
$url = htmlspecialchars($_SERVER['HTTP_REFERER']);
echo "<a href='$url'>back</a>";
?>
1. Many users aren’t aware of their browser back button.
2. Users filling forms often make errors. Therefore, they complete the form, it goes through edit checks on the server, then it displays their input and asks if it is correct. If not, they need to return to correct it. A return button, front-and-center, becomes applicable.
3. The browser back button and the scripted back button do not always behave in the same manner. If you’re looking for a specific behavior, then, it needs to be created.
Oh. The javascript:history.go(-1) and its derivatives returns an Expired Page in IE8