window.clearInterval() : Window Object : Window JAVASCRIPT TUTORIALS


JAVASCRIPT TUTORIALS » Window » Window Object »

 

window.clearInterval()










Syntax








window.clearInterval(interval)



The clearInterval() method clears the interval passed to the method.

The interval has to be previously defined using the setInterval() method.












<html>
    <head>
      <title>Using window.clearInterval()</title>
    <script language="JavaScript1.2">
    <!--
    var counter = 1;

    function startCounter(){
      document.myForm.myText.value = counter++;
    }
    function stopCounter(){
      window.clearInterval(myInterval);
    }
    var myInterval = window.setInterval("startCounter()"1000)
    -->
    </script>
    </head>
    <body onLoad="startCounter()">
    <form name="myForm">
      <input type=TEXT size=20 value="" name="myText">
      <input type=BUTTON value="Clear Interval" onClick="stopCounter()">
    </form>
    </body>
    </html>







HTML code for linking to this page:

Follow Navioo On Twitter

JAVASCRIPT TUTORIALS

 Navioo Window
» Window Object