Appears to be an issue with the beforeunload
event. This is described on jQuery.unload, as
The exact handling of the unload event has varied from version to version of browsers. For example, some versions of Firefox trigger the event when a link is followed, but not when the window is closed. In practical usage, behavior should be tested on all supported browsers, and contrasted with the proprietary beforeunload event.
beforeunload
is more reliable than unload
, but be sure to assign it directly (not bound through jQuery), like this:
window.onbeforeunload = function() { /* do stuff */ };
The unload event itself wasn't meant for work to be done, only cleanup of objects...as garbage collectors get better and better, there's less reason for the browser to even fire the unload event.
So you can try to convert your code to:
window.onbeforeunload = function () {
$.post("track.php", {
async: false,
ip: ip,
plansclick: plansclick,
});
};
However, this functionality appears to not be guarenteed in any browser.
Possible Fix for jQuery.onbeforeunload
Duplicate issue on stackoverflow
Duplicate issue on stackoverflow 2
Duplicate issue on stackoverflow 3