Window setInterval() Method
Window Object
Definition and Usage
The setInterval() method calls a function or evaluates an expression at specified intervals (in milliseconds).
The setInterval() method will continue calling the function until
clearInterval() is called, or the window is
closed.
The ID value returned by setInterval() is used as the parameter for the clearInterval() method.
Tip: 1000 ms = 1 second.
Syntax
| setInterval(code,millisec,lang) |
| Parameter |
Description |
| code |
Required. A reference to the function or the code to be executed |
| millisec |
Required. The intervals (in milliseconds) on how often to execute the
code |
| lang |
Optional. JScript | VBScript | JavaScript |
Browser Support

The setInterval() method is supported in all major browsers.
Example
Example
Call the clock() function every 1000 millisecond. The clock() function
updates the clock. The example
also have a button to stop the clock:
<html>
<body>
<input type="text" id="clock" />
<script language=javascript>
var int=self.setInterval("clock()",1000);
function clock()
{
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("clock").value=t;
}
</script>
</form>
<button onclick="int=window.clearInterval(int)">Stop</button>
</body>
</html>
|
Try it yourself »
|
Window Object

The Altova MissionKit is an integrated suite of tools ideal for:
- XML development
- Web & Web services development
- Data mapping & integration
- Rendering & publishing XML & database data
- XBRL validation, taxonomy editing, transformation & rendering
The MissionKit for XML Developers includes XMLSpy® - the industry-leading XML editor; MapForce® - a
graphical data mapping, conversion, and integration tool; StyleVision® - a visual XSLT stylesheet designer;
DiffDog® - an XML-aware diff/merge tool; and 2 additional tools.
Try all 6 products free for 30 days!
Download a fully-functional free trial
|
|
|
|