I have a really interesting problem on my hands and I don't know what is going on, so any suggestions at all would help me. I was hoping that someone here would be able to help me. Here is my problem:
I have a JS script that looks like this:
function exitTime(){
var endTime = new Date();
var endSec = Math.round(endTime.getTime() / 1000);
imgout = new Image(1,1);
imgout.src = "file.php?endsec="+ endSec;
}
All this does is get the current (milli)seconds from 1-1-1970, then it creates a new image where the source of it is my PHP file that triggers some SQL code to update my DB. Normally this works fine (no problems when the file loads (onload)), but as you might have saw, this function is for exit times and is thus triggered with the onunload JS function, like this:
<body onunload="exitTime()">
Here is the real mind-bender: For me this function will work up to(and not past) 16 seconds from the intial hit (ie, when the page was loaded). So, in other words, when someone stays on the web page anywhere between 1-16 seconds, everything is fine and it will access my PHP file and update my database, but 17 seconds or more will not work except for some very rare occasions.
Can anyone think of any reason why this would be happening? Is there a fix for it? A different way to try that might work better (or at all)?
Please let me know if you can thing of anything! Thanks.
nbagley