Click to See Complete Forum and Search --> : Timer


DoLordBoy
08-18-2003, 10:17 PM
Hey,
Lets say I want to make a page that counts seconds. In other words, if I started it at 0 seconds, if I came back a day later it would still be going.

Any way this can be done?

DoLordBoy
08-18-2003, 10:21 PM
I was probably too vague, I meant if I left it on for a day, when I come back it would be at 8460 seconds or however many are in a day.

Fang
08-19-2003, 01:36 AM
Unlikely, I know that Netscape will stop at some point, other browsers may do the same.
Anyway if you use javascript for this, which uses the users computer time, the clock will run slow due to system interrupts affecting the timer.

AdamGundry
08-19-2003, 02:36 AM
In principle you should be able to use the code below, though I'm not sure about whether browsers could run it for an entire day without errors (it is probably not accurate to the millisecond):
<div id="counter"></div>
<script type="text/javascript">
count = 0;
setInterval('countUp()', 1000);

function countUp(){
count++;
document.getElementById('counter').innerHTML = count;
}
</script>
Adam