JavaScript - bfcache/pageshow event - event.persisted always set to false?

后端 未结 3 1368
灰色年华
灰色年华 2021-02-02 01:59

In a standard Java / SpringMVC / JSP / jQuery web-app, I\'m trying to detect a \"Back\" (or history.go(-1)) event, in order to refresh (AJAX) a summary component/panel content w

3条回答
  •  悲&欢浪女
    2021-02-02 02:05

    I know this is a bit late but this works for me:

    window.onpageshow = function(e) {
    
        if (e.persisted) {
    
            alert("Page shown");
            window.location.reload();
        }
    };
    

    I don't think you need it in the document ready function, just use vanilla as above.

提交回复
热议问题