iOS Safari Mobile doesn't trigger pageshow firing only once

前端 未结 3 464
离开以前
离开以前 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:44

    Hack : This is what worked for me

    var myCustomEvent = (navigator.userAgent.match('iPhone') != null) ? 'popstate' : 'pageshow';
    
    $(window).on(myCustomEvent, function(e) {
     ...
    }
    

    For some reason popstate triggers everytime when page state changes in iOS but not in Android.

提交回复
热议问题