English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
clearTimeout()The method cancels the previous timeout set by callingsetTimeout()Established timeout.
The ID value returned by setTimeout() is used as the parameter for the clearTimeout() method.
Note:To be able to use the clearTimeout() method, a variable must be used when creating the timeout method:
t = setTimeout("javaScript function", milliseconds);
Then, if the function has not been executed yet, you can stop the execution by calling the clearTimeout() method:
clearTimeout(t);
window.clearTimeout(var)
var t; function myFunc() { t = setTimeout(function(){ alert("Hello world"); }, 2000); } function myStopFunc() { clearTimeout(t); }Test and See‹/›
The numbers in the table specify the first browser version that fully supports the clearInterval() method:
Method | |||||
clearTimeout() | 1 | 1 | 4 | 1 | 4 |
Parameters | Description |
---|---|
var | setTimeout()The Name of the Timer Returned by the Method |
Return Value: | None |
---|
Click the 'Start Counting' button below to start the timer. Click the 'Stop Counting' button to stop counting:
Window (Window) Reference:setTimeout() Method
Window (Window) Reference:setInterval() Method
Window (Window) Reference:clearInterval() Method
Window (Window) Reference:requestAnimationFrame() Method