Name
Window.setTimeout( ) — defer execution of code
Availability
JavaScript 1.0
Synopsis
window.setTimeout(code,delay)
Arguments
-
code A string that contains the JavaScript code to be executed after the
delayhas elapsed.-
delay The amount of time, in milliseconds, before the JavaScript statements in the string
codeshould be executed.
Returns
An opaque value (“timeout id”) that can be passed to the
clearTimeout( ) method to cancel the execution of
code.
Description
The setTimeout( ) method defers the execution of the JavaScript statements
in the string code for
delay milliseconds. Once the specified
number of milliseconds has elapsed, the statements in
code are executed normally. Note that they
are executed only once. To execute code repeatedly,
code must itself contain a call to
setTimeout( ) to register itself to be executed
again. In JavaScript 1.2, you can use Window.setInterval( ) to register code that is executed at periodic intervals.
The statements in the string code are
executed in the context of window; i.e.,
window is the current window for those
statements. If more than one statement appears in
code, the statements must be separated by
semicolons.