Reputation: 4665
I am using this snippet, it works in all actions except if user clicks back button to leave the page.
$(window).bind('hashchange', function ()
{
$.post("track.php",
{
ip: ip,
referer: referer,
});
});
$(window).bind('beforeunload', function ()
{
$.post("track.php",
{
ip: ip,
referer: referer,
});
});
$(window).unload(function ()
{
$.post("track.php",
{
ip: ip,
referer: referer,
});
});
Is it possible to catch if user clicks back button ?
Upvotes: 0
Views: 181
Reputation: 7898
Make your ajax request synchronous. This doesn't work in opera last I checked though.
$.ajax({
async: false
});
Upvotes: 3