ClearTimeout function in javascript
by kalai[ Edit ] 2008-03-17 15:36:22
The clearTimeout method is available on window objects. It is used to clear a delay to a function that was set using setTimeout().
<script language="javascript">
var intValue = 0
function myMethod(){
alert('timeout');
}
</script>
<button onclick="intValue=window.setTimeout('myMethod()', 1000);">Start timeout</button>
<button onclick="intValue=window.clearTimeout(intValue);">Stop timeout</button>
In the above code when start 'timeout button' is clicked then myMethod() function is called repeatedly called in the interval of 1 second, when 'stop timeout' button is clicked it clears the delay value set using setTimeout() in the variable 'intValue'.