FS-11283: iOS doesn't support beforeunload, use recommended pagehide for that platform

$.verto.unloadJobs queue leverages the 'beforeunload' event to perform work
prior to browser page unload.

However, iOS does not support that event. Its equivalent event is 'pagehide'.

This patch uses the pagehide event on iOS, and beforeunload for all others.
This commit is contained in:
Chad Phillips 2018-07-26 14:19:28 -05:00
parent d5af929660
commit 954b2564b2

View File

@ -2713,10 +2713,17 @@
$.verto.unloadJobs = [];
$(window).bind('beforeunload', function() {
for (var f in $.verto.unloadJobs) {
$.verto.unloadJobs[f]();
}
var unloadEventName = 'beforeunload';
// Hacks for Mobile Safari
var iOS = ['iPad', 'iPhone', 'iPod'].indexOf(navigator.platform) >= 0;
if (iOS) {
unloadEventName = 'pagehide';
}
$(window).bind(unloadEventName, function() {
for (var f in $.verto.unloadJobs) {
$.verto.unloadJobs[f]();
}
if ($.verto.haltClosure)
return $.verto.haltClosure();