Mega Code Archive

 
Categories / JavaScript Tutorial / Window
 

Window clearTimeout()

Syntax window.clearTimeout(timeout) The clearTimeout() method clears the timeout passed to the method. The timeout has to be previously defined using the setTimeout() method. <html>     <head>     <script language="JavaScript">     <!--     function showTime(){       myTime = new Date();       myString = myTime.getHours() + ":" + myTime.getMinutes() + ":";       myString += myTime.getSeconds();       document.myForm.myText.value = myString;     }     function stopTime(){       window.clearTimeout(myTimeout);     }     var myTimeout = window.setTimeout("showTime()", 1000)     -->     </script>     </head>     <body>     <form name="myForm">       <input type=TEXT size=20 value="" name="myText">       <input type=BUTTON value="Clear Timeout" onClick="stopTime()">     </form>     </body>     </html>