clearTimeout
Summary
Cancels a time-out that was set with the setTimeout method.
Method of dom/Windowdom/Window
Syntax
window.clearTimeout(/* see parameter list */);
Parameters
timerID
- Data-type
- Number
Integer that specifies the time-out setting returned by a previous call to the setTimeout method.
Return Value
No return value
Examples
var alarm = {
remind: function(aMessage) {
alert(aMessage);
delete this.timeoutID;
},
setup: function() {
this.cancel();
var self = this;
this.timeoutID = window.setTimeout(function(msg) {self.remind(msg);}, 1000, "Wake up!");
},
cancel: function() {
if(typeof this.timeoutID == "number") {
window.clearTimeout(this.timeoutID);
delete this.timeoutID;
}
}
};
window.onclick = function() { alarm.setup() };
Attributions
Mozilla Developer Network : [clearTimeout Article]
Microsoft Developer Network: [clearTimeout Method Article]