Hi there,
I've set up a page that records the times (in a database) users login to it (start time), and I wanted to be able to determine the times they left the page (leave time), so I used the javascript onUnload function along with an Ajax request. This is my script:
window.onunload = function () {
new Ajax.Request('end.php');
}
Where end.php is a php file with the code that submits the time info to the database.
This works perfectly in Firefox and IE7. The problem I have is that the AJAX doesn't seem to be working in Safari or Chrome, and the onUnload() function doesn't work in Opera (I'm not too worried about this one - mainly want Safari to work). I'm not sure of how this works in IE6, I haven't been able to test it yet.
I need this to work in as many browsers as possible because it's important that leave times be recorded for this page.
Is there something wrong with the code I've written?
Is there another way to achieve what I am trying to do?
Thanks in advance!