From: Chad Phillips Date: Thu, 26 Jul 2018 19:19:28 +0000 (-0500) Subject: FS-11283: iOS doesn't support beforeunload, use recommended pagehide for that platform X-Git-Tag: v1.8.2~1^2~69^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=954b2564b2e4582949825988f30dde3fb16d1347;p=thirdparty%2Ffreeswitch.git 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. --- 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();