Basic HTML version of Foils prepared 23 June 1997

Foil 63 Timeout methods

From JavaScript Tutorial for Certificate Course UC Web applications Certificate -- Summer 97. by Geoffrey C. Fox, Tom Scavo

setTimeout Examples for Foil 63
JavaScript has a pair of timeout methods
// Call setTimeout and assign a handle:
yourID = setTimeout(exp, msecs);
// Abort process started by setTimeout:
clearTimeout(yourID);
setTimeout starts a timer that causes expression exp to be evaluated after a time interval of msecs milliseconds
These methods can be used to animate text or images, or make a display change after a given time interval
  • Also to start a daemon, which monitors what's going on!
Note setTimeout does not start a loop, just a single timing. Thus clearTimeout need not be called unless abnormal termination is required
If you want a loop, ensure exp restarts a new setTimeout



Northeast Parallel Architectures Center, Syracuse University, npac@npac.syr.edu

If you have any comments about this server, send e-mail to webmaster@npac.syr.edu.

Page produced by wwwfoil on Wed Apr 1 1998