Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IOS 10.3.3 Iphone Safari beforeunload, unload, pagehide wont work

I'm trying to catch beforeunload, unload, pagehide events on iPhone Safari (602.1) IOS 10.3.3. But it seems that on iPhone these events don't fire, and the funny part is that on iPad which has same versions of browser and IOS, the events do fire. The only difference that I noticed was that iPad gives you the tab option but iPhone doesn't. Is there any way to catch these events on iPhone IOS 10.3.3?

Note: These events do fire on iPhone IOS 8.4.1.

like image 212
ato Avatar asked Nov 06 '17 10:11

ato


1 Answers

I use event pagehide with (partial) success, see supported Events in Apple Guides.

The only situation that pagehide does not work is on iPhone 10, and when the website is stored to the application 'springboard'. The web application (build with Vuejs) looks like a native App. Leaving the 'app' does not fire pagehide. On older iPhones and iPads in the same situation, pagehide fires.

window.addEventListener('pagehide', () => { // do something }

like image 119
Frank Welten Avatar answered Nov 20 '22 16:11

Frank Welten