返回并重新加载页面 - 一个按钮

Go back and reload page - one button

本文关键字:一个 按钮 新加载 加载 返回      更新时间:2023-09-26

我需要回到上一页并刷新它。我使用 history.go(-1),但上一页上的表单没有重新加载。

感谢您的回答。

截至2014年6月10日,我已经测试了最新的Chrome 35,FireFox 29和IE 11。只有Firefox在我执行location.history.back()时没有重新加载。所以我把 location.history.back() 替换为

location.href = document.referrer

所以我的后退按钮现在的工作方式是这样的:

<a href="#" onclick="location.href = document.referrer; return false;">Back</a>

如果重新打开页面,它应该会自动刷新。您可能可以通过document.referrer获取引用页面的网址希望有帮助。

我想

我发明了一种做到这一点的方法。通过向 url 添加一个随机参数,我们强制浏览器刷新...

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

上一页上使用以下

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

在 ASP 的情况下

另外检查这个