From 954b2564b2e4582949825988f30dde3fb16d1347 Mon Sep 17 00:00:00 2001 From: Chad Phillips Date: Thu, 26 Jul 2018 14:19:28 -0500 Subject: [PATCH] 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. --- html5/verto/js/src/jquery.verto.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/html5/verto/js/src/jquery.verto.js b/html5/verto/js/src/jquery.verto.js index c913ca4140..a2e02e4bdc 100644 --- a/html5/verto/js/src/jquery.verto.js +++ b/html5/verto/js/src/jquery.verto.js @@ -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();