Document comes with the method:
Cyclic execution: var Timeid = Window.setinterval ("Method name or method", "delay"); Window.clearinterval (Timeid);
Timed execution: var tmid = Window.settimeout ("Method name or method", "Time delay"); Window.cleartimeout (Tmid);
To illustrate:
A. When a parameter is not required in the method to be executed
<script type= "Text/javascript" >
Loop execution, once every 3 seconds Showalert ()
Window.setinterval (Showalert, 3000);
function Showalert ()
{
Alert ("AAAAA");
}
Scheduled execution, 5 seconds after the show ()
Window.settimeout (show,5000);
Function Show ()
{
Alert ("BBB");
}
</script>
B. When a parameter is required in the method to be executed
<script type= "Text/javascript" >
Loop execution, once every 3 seconds Showalert ()
Window.setinterval (function () {
Showalert ("AAAAA");
}, 3000);
function Showalert (mess)
{
alert (mess);
}
Timed execution, 5 seconds after execution Showalert ()
Window.settimeout (function () {
Showalert ("bbbbbb");
},5000);
</script>
JS Timer function