Is there any way to use [removed] on Mobile Safari for iOS devices?

前端 未结 4 1645
春和景丽
春和景丽 2020-11-27 17:19

Looks like Apple has disabled the window.onbeforeunload event for iOS devices (iPhone, iPad, iPod Touch). Unfortunately I can\'t find any documentation as to why this event

4条回答
  •  天命终不由人
    2020-11-27 17:43

    I was having the same problem. it seems safari browser in iphone triggers only focus and blur events and almost every other event is not triggered, e.g.(pagehide, pageshow, visibility change) but the good news is focus and blur event are supported and triggered on iphone, ipad & android mobiles as well.

        window.addEventListener('focus', function(){
           // do stuff
         });
    
       window.addEventListener('blur', function(){
           // do stuff
         });
    

    hope this helps anyone.

提交回复
热议问题