Window clearTimeout()Method
Example
Prevent the setTimeout() method from executing the function:
Try it yourself »
Definition and Usage
The clearTimeout() method can cancel the timed operation set by thesetTimeout()setTimeout() method.
The parameter of the clearTimeout() method must be the ID value returned by setTimeout().
Note:To use the clearTimeout() method, you must use a global variable when creating the timed operation:
myVar = setTimeout("javascript function", milliseconds);
If the method has not yet been executed, we can use clearTimeout() to prevent it.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
| Method | |||||
|---|---|---|---|---|---|
| clearTimeout() | 1.0 | 4.0 | 1.0 | 1.0 | 4.0 |
Syntax
clearTimeout(id_of_settimeout)
| Parameter | Description |
|---|---|
| id_of_setinterval | The return value obtained when calling the setTimeout() function. Using this returned identifier as a parameter can cancel the timed execution operation set by that setTimeout(). |
Technical Details
| Return value: | No return value. |
|---|
More Examples
Example
The following example starts the counting program by clicking the "Start count!" button. After clicking the "Stop count!" button to stop it, you can click the "Start count!" button again to restart counting.
Try it yourself »
Related Pages
Window Object:setInterval() Method
Window Object:setTimeout() Method
Window Object:clearInterval() Method
Other Extensions
Window Object