The code below will allow you to put an intelligent back link on to your pages. When used sparingly it can add more value to your site than using the history property.
<script language="JavaScript"
type="text/javascript">
<!--
function checkurl()
{
var myurl = "http://www.yourwebsite.com";
if(document.referrer.substring(0,26) == myurl)
{ document.location.href=document.referrer; }
else
{ document.location.href=myurl; }
}
// -->
</script>
Normally using the history.go(-1) property takes you back to the page you came from - which could be from another site. This would mean your back link could be redirecting users away from your site.
This small script will only go back to the page you came from IF that page is on your site. If the page is from another url or from an email link - the back link will take you to your homepage which means you get to keep your visitor a while longer :)
Click here to see the page you came from.
There are only a couple of changes you will need to make for it to work on your pages
Finally, to create the link add the following code into your document.
<a href=" <!-- insert url --> " onclick="checkurl();return false;">back</a>
Replace <!-- insert url --> with the url of your homepages. This means that non Javascript browsers will be sent to your homepage if they click on the back link.