Alternative to onbeforeunload for Safari on iOS?

I’m using window.onbeforeunload to prevent an iframe from redirecting the parent window. Unfortunately this doesn’t work in the mobile version of Safari. window.unload and pagehide don’t seem to do the trick either.

var prevent_bust=0;
window.onbeforeunload=function(){prevent_bust++;};
function rdrctrl(){
  if(prevent_bust>0){
    prevent_bust-=2;
    if(blockredir){window.top.location='./204.php';}
  }
};
setInterval(rdrctrl,1);


Source: ios

1 Comment

  1. Edwin

    For Safari on iOs you can do this:

    window.addEventListener('popstate', function(e) {$('#loading').hide()});
    Reply

Leave a Reply