English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Window clearTimeout() Method

JavaScript Window Object

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);

Syntax:

window.clearTimeout(var)
var t;
function myFunc() {
   t = setTimeout(function(){ alert("Hello world"); }, 2000);
}
function myStopFunc() {
   clearTimeout(t);
}
Test and See‹/›

Browser Compatibility

The numbers in the table specify the first browser version that fully supports the clearInterval() method:

Method
clearTimeout()11414

Parameter Values

ParametersDescription
varsetTimeout()The Name of the Timer Returned by the Method

Technical Details

Return Value:None

More Examples

Click the 'Start Counting' button below to start the timer. Click the 'Stop Counting' button to stop counting:

0
Test and See

Related References

Window (Window) Reference:setTimeout() Method

Window (Window) Reference:setInterval() Method

Window (Window) Reference:clearInterval() Method

Window (Window) Reference:requestAnimationFrame() Method

JavaScript Window Object