Timed Events
It can be useful to call a function after a time delay,
or over and over again based upon a preset time interval.
Common examples include causing an advertisement to appear a few seconds after a page load,
or to set a page to auto reload itself every few minutes to keep the content current.
Another common example is a page that says you will be automatically transferred to some other page
in 8 seconds (or whatever) otherwise click here to transfer now.
The setTimeout() and setInterval() functions are built-in to the JavaScript language
setTimeout( my_function , 1000); // my_function() will be called ONCE after 1 second
setInterval( my_function , 1000); // my_function() will be called EVERY 1 second henceforth
The first parameter is the name of a function.
The second parameter is a time in milliseconds (1/1000 of a second).
There is a timeout and interval set in this example when the page first loads.
You have probably already seen visual evidence of what they do.
You can also initiate timers on user events such as onclick.
Click me for a delayed alert after 5 seconds.