How to use Window Object SetInterval in JavaScript

In this example I am going to explain about window object SetInterval() method in JavaScript.
  • 2286

JavaScript Window object SetInterval() Method

JavaScript SetInterval() method use for call a function at again and again at specifics time interval. The method calling function will be continue until ClearInterval() method is called or window is closed.


Window.SetInterval(Function(), Milisecond)




    <textarea id="txt" cols="20" rows="2"></textarea>

    <script type="text/javascript">

        var int = self.setInterval("myfun()", 1000);

        function myfun() {

            var mm = new Date();

            var t = mm.toLocaleTimeString();

            document.getElementById("txt").value = t;





    <button onclick="int=window.clearInterval(int)">

        click me</button>







You may also want to read these related articles: here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.