Javascript go back to previous page and refresh

Any half-ass JavaScript guru or newbie knows that you can go back to the previous page with the history.go(-1) statement in JavaScript, but what if you have to do the same thing but with a page refresh? Well one newbie type thought was to use :

<body onload="document.refresh();">

…in the previous page’s body tag, but that’s not cool if you don’t know what the previous page will be or don’t want that page to refresh for people landing on the page another way other than your special link. So, here’s what I ended up using in a link to go back to previous page, no matter what it may be, and refresh it simultaneously:

<a href=’javascript:window.location = document.referrer;’>Click here to refresh and view changes</a>.<br />

Problem solved! Enjoy…

5 Replies to “Javascript go back to previous page and refresh”

Leave a Reply

Your email address will not be published. Required fields are marked *