Compare Revisions

Window.setInterval

Revision 25908:

Revision 25908 by Ceth on

Revision 25909:

Revision 25909 by aeon on

Title:
window.setInterval
window.setInterval
Slug:
DOM/window.setInterval
DOM/window.setInterval
Tags:
DOM, Gecko, "Gecko DOM Reference", MakeBrowserAgnostic
DOM, Gecko, "Gecko DOM Reference", MakeBrowserAgnostic
Content:

Revision 25908
Revision 25909
n20<i>intervalID</i> = window.setInterval(<i>func</i>, <i>delay</i>[n20<em>intervalID</em> = window.setInterval(<em>func</em>, <em>delay
>, <i>param1</i>, <i>param2</i>, ...]);></em>[, <em>param1</em>, <em>param2</em>, ...]);
21<i>intervalID</i> = window.setInterval(<i>code</i>, <i>delay</i>)21<em>intervalID</em> = window.setInterval(<em>code</em>, <em>delay
>;></em>);
n28        <code>intervalID</code> is a unique interval ID you can pn28        <code>intervalID</code> is a unique interval ID you can p
>ass to <code><a href="en/DOM/window.clearInterval">clearInterval(>ass to <code><a href="/en/DOM/window.clearInterval" title="en/DOM
>)</a></code>.>/window.clearInterval">clearInterval()</a></code>.
n31        <code>func</code> is the <a href="en/Core_JavaScript_1.5_n31        <code>func</code> is the <a href="/en/Core_JavaScript_1.5
>Reference/Objects/Function">function</a> you want to be called re>_Reference/Global_Objects/Function" title="en/Core_JavaScript_1.5
>peatedly.>_Reference/Global_Objects/Function">function</a> you want to be c
 >alled repeatedly.
n100      You can cancel the interval using <code><a href="en/DOM/winn100      You can cancel the interval using <code><a href="/en/DOM/wi
>dow.clearInterval">window.clearInterval()</a></code>.>ndow.clearInterval" title="en/DOM/window.clearInterval">window.cl
 >earInterval()</a></code>.
n103      If you wish to have your function called <i>once</i> after n103      If you wish to have your function called <em>once</em> afte
>the specified delay, use <code><a href="en/DOM/window.setTimeout">r the specified delay, use <code><a href="/en/DOM/window.setTimeo
>>window.setTimeout()</a></code>.>ut" title="en/DOM/window.setTimeout">window.setTimeout()</a></cod
 >e>.
nn105    <h4>
106      Callback arguments
107    </h4>
108    <p>
109      The setInterval() will pass the number of milliseconds late
 > the callback was called into the callback function, which can co
 >nfused it if it expects something else as an argument. To sideste
 >p that problem, use an anonymous function to call your callback.
110    </p>
111    <p>
112      Example:
113    </p>
114    <pre>
115intervalID = setInterval(funcflashText, 1000);
116</pre>
n109      When you pass a method to <code>setInterval()</code> (or ann121      When you pass a method to <code>setInterval()</code> (or an
>y other function, for that matter), it will be invoked with a wro>y other function, for that matter), it will be invoked with a wro
>ng <code>this</code> value. This problem is explained in detail i>ng <code>this</code> value. This problem is explained in detail i
>n the <a href="en/Core_JavaScript_1.5_Reference/Operators/Special>n the <a href="/en/Core_JavaScript_1.5_Reference/Operators/Specia
>_Operators/this_Operator#Method_binding">JavaScript reference</a>>l_Operators/this_Operator#Method_binding" title="en/Core_JavaScri
>.>pt_1.5_Reference/Operators/Special_Operators/this_Operator#Method
 >_binding">JavaScript reference</a>.
tt128    </p>
129    <p>
116    </p>{{ languages( { "fr": "fr/DOM/window.setInterval", "ja": 130      {{ languages( { "fr": "fr/DOM/window.setInterval", "ja": "j
>"ja/DOM/window.setInterval", "pl": "pl/DOM/window.setInterval" } >a/DOM/window.setInterval", "pl": "pl/DOM/window.setInterval" } ) 
>) }}>}}
131    </p>

Back to History