JavaScript: The Definitive Guide

25.317. Window.setInterval( ): periodically execute specified code

JavaScript 1.2:

25.317.1. Synopsis

window.setInterval(code, interval)

25.317.1.1. Arguments

code

A function to be periodically invoked or a string of JavaScript code to be periodically evaluated. If this string contains multiple statements, they must be separated from each other by semicolons. In IE 4 (but not later versions), this argument must be a string.

interval

The interval, in milliseconds, between invocations or evaluations of code.

25.317.1.2. Returns

A value that can be passed to Window.clearInterval( ) to cancel the periodic execution of code.

25.317.2. Description

setInterval( ) repeatedly invokes or evaluates the function or string specified by code, at intervals of interval milliseconds.

setInterval( ) returns a value that can later be passed to Window.clearInterval( ) to cancel the execution of code.

setInterval( ) is related to setTimeout( ). Use setTimeout( ) when you want to defer the execution of code but do not want it to be repeatedly executed. See Window.setTimeout( ) for a discussion of the execution context of code.

25.317.3. See Also

Window.clearInterval( ), Window.setTimeout( )

Категории