Reputation: 41
I need a way to go back to a previous page after the current page has been reloaded.
At the moment if I use my simple history -1 on the page that has been reloaded in jQuery it will send me back to the same (reloaded)page as is only expected.
Is there a way to identify that the page is the same page and therefore ignore it as a relevant option to go back to?
Here is the code I am using at the moment:
$(document).ready(function(){
$('a.back-link').click(function(){
parent.history.back();
return false;
});
});
Thanks,
Aidan
Upvotes: 0
Views: 4663
Reputation: 2528
You could always use document.referrer to get the address of the page that originally referred you to your current page (location.reload() should not affect the referrer variable)
location.href = document.referrer;
A working example can be found here http://iamdevelop.in/referrer
Upvotes: 2