I'm playing around with using some javascript to add extra functionality to a back button on my website. Right now I have a set of javascript that looks like this:
$(".back-link a").live("click", function(){
history.go(-1);
return false;
});
Now, it works great but I'm trying to make it as bulletproof as possible and one issue I foresee is that if someone lands on a project page and hasn't come to it via my home page then going back in their history one step will take them off my site. Obviously, this isn't what I want.
My guess is it would be a simple case of doing an if-statement but I'm not sure what or how to test for it. I suppose I could just test to make sure the base of the URL is my site but I'm not sure how.
Any tips or directions would be great.