How to use Window Object SetInterval in JavaScript
In this example I am going to explain about window object SetInterval() method in JavaScript.
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.
Syntax
Window.SetInterval(Function(), Milisecond)
|
Example
<html>
<head>
<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;
}
</script>
</head>
<body>
<button onclick="int=window.clearInterval(int)">
click me</button>
</body>
</html>
|
Output
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