This is what I would do:

//inside <head>
leavingSite = false;
window.onunload = function(){
 leavingSite = true;
 setTimeout("if(leavingSite){ [insert ajax] }",2000);
}

If the new page does not load in 2 seconds or the user left the site,
then the script will execute. (although I'm not sure what will happen
if they close the browser)
Keep in mind I haven't tested this code yet, so give it a go.

~Sean

Reply via email to