Name

setInterval( ) — NN 4 IE 4 DOM n/a

Synopsis

setInterval(expression, msecs[, args | language])

Starts a timer that continually invokes the expression every msecs. Other scripts can run in the time between calls to expression. This method is useful for starting animation sequences that must reposition an element along a path at a fixed rate of speed. The expression might be a function that moves the element by a fixed pixel distance along one axis. The function would be invoked at an interval set by the msecs parameter. This method returns an ID that should be saved as a global variable and be available as the parameter for the clearInterval( ) method to stop the looping timer.

Navigator and Internet Explorer diverge in the use of the third parameter. Navigator lets you pass one or more parameters (as a comma-delimited list in a string) for the function acting as the expression parameter. Internet Explorer lets you specify the scripting language of the expression (if it is not the default JavaScript).

Returned Value

Integer acting as an identifier.

Parameters

expression

Any script expression as a string, but most commonly a function. The function name with parentheses is placed inside the parameter’s quoted string.

msecs

The time in milliseconds between invocations of the expression.

args

An optional comma-delimited list of parameters to be passed to a function used as the expression parameter.

language

An optional scripting language specification of the expression parameter (default ...

Get Dynamic HTML: The Definitive Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.