简体   繁体   中英

Go back and reload page - one button

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>

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.

on the previous page use the following

 <% Response.AddHeader "Pragma", "no-cache" %>
  <% Response.Expires = -1 %>

in case of asp

in addition check this

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);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM