Javascript History.Back 刷新
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4657545/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
History.Back with refresh
提问by Larsi
I would like to have the History.back();
functionality with a complete refresh of previous page.
我希望具有History.back();
完全刷新上一页的功能。
Any idea how to do that (and make it work in IE, FF and Chrome).
任何想法如何做到这一点(并使其在 IE、FF 和 Chrome 中工作)。
采纳答案by stecb
You could redirect (by window.location) to document.referrer
您可以(通过 window.location)重定向到 document.referrer
i.e.
IE
window.location.href = document.referrer;
Internet Explorer fix for passing referrer to a particular location:
用于将引用者传递到特定位置的 Internet Explorer 修复:
if(IE){ //IE, bool var, has to be defined
var newlocation = document.createElement('a');
newlocation.href = URLtoCall;
document.body.appendChild(newlocation);
newlocation.click();
}
回答by Mori
You can also use the location replace() method:
您还可以使用 location replace() 方法:
window.location.replace(document.referrer)