Availability
JavaScript 1.2; IE 4 supports only one of the two forms
Synopsis
window.setInterval(code, interval)window.setInterval(func, interval,args...)
Arguments
code
A string of JavaScript code to be periodically executed. If this
string contains multiple statements, they must be separated from each
other by semicolons.
func
A JavaScript function to be periodically executed. This form of the
method is not available in IE 4.
interval
An integer that specifies the interval, in milliseconds, between
invocations of code or
func.
args...
Any number of arbitrary values to be passed as arguments to each
invocation of func.
Returns
A value that can be passed to Window.clearInterval(
) to cancel the periodic execution of
code or func.
Description
setInterval( ) repeatedly executes the JavaScript
statements specified in the string code,
at intervals of interval milliseconds.
In Netscape 4, but not IE 4, a function may be passed as the first
argument instead of a string. In this form of setInterval(
), the specified function, func,
is repeatedly invoked, at intervals of
interval milliseconds. Any additional
argument values, args, passed to
setInterval( ) are passed as arguments to each
invocation of func( ).
In both forms, the setInterval( ) method returns a
value that can later be passed to Window.clearInterval(
) to stop code or
func from being repeatedly executed.
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 Also
Window.clearInterval( ), Window.setTimeout( )
•
Table of Contents
•
Index
•
Reviews
•
Examples
•
Reader Reviews
•
Errata
JavaScript: The Definitive Guide, 4th Edition
By
David Flanagan
Publisher
: O'Reilly
Pub Date
: November 2001
ISBN
: 0-596-00048-0
Pages
: 936
Slots
: 1
This fourth edition of the definitive reference to
JavaScript, a scripting language that can be embedded
directly in web pages, covers the latest version of the
language, JavaScript 1.5, as supported by Netscape 6 and
Internet Explorer 6. The book also provides complete
coverage of the W3C DOM standard (Level 1 and Level 2),
while retaining material on the legacy Level 0 DOM for
backward compatibility.