$.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.
$.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();