History.Back with refresh

我的梦境 提交于 2019-11-27 00:37:35

问题


I would like to have the History.back(); functionality with a complete refresh of previous page.

Any idea how to do that (and make it work in IE, FF and Chrome).


回答1:


You could redirect (by window.location) to document.referrer

i.e.

window.location.href = document.referrer;

Internet Explorer fix for passing referrer to a particular location:

if(IE){ //IE, bool var, has to be defined
    var newlocation = document.createElement('a');
    newlocation.href = URLtoCall;
    document.body.appendChild(newlocation);
    newlocation.click();
}



回答2:


You can also use the location replace() method:

window.location.replace(document.referrer)


来源:https://stackoverflow.com/questions/4657545/history-back-with-refresh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!