I need to go back on previous page and refresh it. I use history.go(-1) but the form on the previous page is not reloaded.
Thanks for answers.
As per 10th June 2014, I have tested latest Chrome 35, FireFox 29 and IE 11. Only Firefox didn't do a reload when I did location.history.back(). So I replaced location.history.back() with
location.href = document.referrer
So my back button now works like this:
<a href="#" onclick="location.href = document.referrer; return false;">Back</a>
location.history.back(); location.history.back();
and then a solution from stackoverflow.com/questions/3715047/…. But I haven't tested it.
Commented
Jan 18, 2017 at 6:05
If you reopen the page it should automatically refresh. You can probably get the url of the referring page via document.referrer
Hope that helps.
I think I invented a way of doing this. By adding a random parameter to url, we force browser to refresh...
var backLocation = document.referrer;
if (backLocation) {
if (backLocation.indexOf("?") > -1) {
backLocation += "&randomParam=" + new Date().getTime();
} else {
backLocation += "?randomParam=" + new Date().getTime();
}
window.location.assign(backLocation);
}