Safari 后退按钮在使用时不会重新加载页面 [英] Safari back button doesn't reload page when used

查看:75
本文介绍了Safari 后退按钮在使用时不会重新加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题已在旧版 Safari 中解决(Safari 后退按钮问题).尽管运行最新的 Safari (9.0.1),但上一个答案中列出的解决方案都不再有效.当使用 safari 上的后退按钮时,有人有刷新/重新加载"页面的解决方案吗?

This issue -was- solved in older versions of Safari (The Safari Back Button Problem). Although running the latest Safari (9.0.1), none of the solutions listed on the previous answer work anymore. 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.

<body onunload=""> 

推荐答案

其他答案将东西绑定到 window.onpageshow,但这是唯一对我有用的版本:一旦您的页面处于最终状态,您就不会想要超过重定向,您可以绑定 pageshow 事件,然后检查persisted"属性是否为真,以确定是否应该重新加载它.

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.addEventListener("pageshow", function(evt){
        if(evt.persisted){
        setTimeout(function(){
            window.location.reload();
        },10);
    }
}, false);

这篇关于Safari 后退按钮在使用时不会重新加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆