...

View Full Version : JavaScript timer?



angst
11-01-2006, 05:16 PM
Hello,
I've found this simple time:




var start=new Date();
start=Date.parse(start)/1000;
var counts=5;
function CountDown(){
var now=new Date();
now=Date.parse(now)/1000;
var x=parseInt(counts-(now-start),20);
if(document.form1){document.form1.clock.value = x;}
if(x>0){
timerID=setTimeout("CountDown()", 100)
}else{
GetChat();
}
}

window.setTimeout('CountDown()',100);
var ran = Math.round(Math.random() * 899999) + 100000;



which I'm using to triger a simple ajax update on a web page.
this seems to work fine.

my question is, how can i have it start back at the beginning once it reachs 0 over and over again. so that it will continue refreshing the ajax content every 5 seconds?


thanks in advance for your time!
-Ken

angst
11-01-2006, 06:24 PM
maybe i should re-word this,

I'm just looking for a way to triger an event every 5-10 seconds.

is this possible?

angst
11-01-2006, 08:05 PM
ok, i found what i was looking for:

setInterval("GetChat()", 5000);

does exactly what i needed.

-Ken



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum