简体   繁体   English

Safari back按钮在使用时不会重新加载页面

[英]Safari back button doesn't reload page when used

This issue -was- solved in older versions of Safari ( The Safari Back Button Problem ). 这个问题在旧版本的Safari( Safari后退按钮问题 )中得到了解决。 Although running the latest Safari (9.0.1), none of the solutions listed on the previous answer work anymore. 虽然运行最新的Safari(9.0.1),但上一个答案中列出的解决方案都不再有效。 Does anyone have a solution to "refresh/reload" the page when the back button on safari is used? 当使用safari上的后退按钮时,有没有人有“刷新/重新加载”页面的解决方案?

This -was- a way to detect if the page was accessed using the back-button. 这是一种检测页面是否使用后退按钮访问的方法。 Although doesn't work in the version of Safari I'm using. 虽然在我正在使用的Safari版本中不起作用。

<body onunload=""> 

Other answers bind things to window.onpageshow, but this is the only version that works for me: once your page is in a final state that you don't want to outlive a redirect, you can just bind the pageshow event and then check for the "persisted" property being true to determine if you should reload it. 其他答案将事物绑定到window.onpageshow,但这是唯一适用于我的版本:一旦您的页面处于最终状态,您不想超过重定向,您可以绑定pageshow事件然后检查“持久”属性为true,以确定是否应重新加载它。

window.addEventListener("pageshow", function(evt){
        if(evt.persisted){
        setTimeout(function(){
            window.location.reload();
        },10);
    }
}, false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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