iOS Safari Mobile doesn't trigger pageshow firing only once

前端 未结 3 461
离开以前
离开以前 2021-01-14 07:09

The iOS Safari doesnt\'t seem to trigger pageshow event in the following situation.

Lets say I have 3 pages

  • Page A : (has some code code on pageshow ev
3条回答
  •  别那么骄傲
    2021-01-14 07:50

    The popstate event doesn't seem to work any more, at least for me. I worked out some third-party script on my page was breaking this, but wasn't able to work out which one. I came up with this hack:

    addEventListener('pageshow', () => {
      history.replaceState({}, document.title, window.location.pathname);
      // called on initial load and first back
    });
    
    addEventListener('popstate', () => {
      // called on all back events
    });
    

提交回复
热议问题