Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > timer function

Thread Tools

timer function

Dr John Stockton
Posts: n/a
JRS: In article <(E-Mail Removed)>, dated Tue, 9 Nov
2004 19:20:03, seen in news:comp.lang.javascript, Darren Showers
<(E-Mail Removed)> posted :
>I'm running a timer function that counts down from set time frames.
>It has an odd tendency to drop 2 seconds at the beginning but then
>work fine the rest of the way. Can anyone suggest what could be
>happening here?

> if (running) {
> timerID = setTimeout("showCountDown()",1000)
> }

That gives a delay of 1000 ms, rounded up to the next clock tick; there
will also be the delay in executing the code that precedes it.

You need to calculate the delay to the next second, or say 10% of the
way through it, as for example

setTimeout("Tock()", 1100-D%1000)

where D = new Date().

Read the c.l.j newsgroup FAQ; see below; see js-date0.htm#TaI .

John Stockton, Surrey, UK. ? Turnpike v4.00 IE 4
<URL:> JL/RC: FAQ of news:comp.lang.javascript
<URL:> jscr maths, dates, sources.
<URL:> TP/BP/Delphi/jscr/&c, FAQ items, links.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
I know about the shutdown timer, is there a "switch on" timer... Mal Carter Computer Support 3 01-12-2008 01:58 AM
page timer, or redirect timer Simon ASP .Net 1 11-04-2005 07:14 PM
System.Timers.Timer/System.Threading.Timer Not Firing At All on Dev Server ASP .Net 1 02-22-2005 09:41 PM
write a function such that when ever i call this function in some other function .it should give me tha data type and value of calling function parameter komal C++ 6 01-25-2005 11:13 AM
System.Timers.Timer vs. System.Threading.Timer Kelsang Wangchuk ASP .Net 0 07-31-2003 04:28 PM