Pages

Monday, February 28, 2011

how to repeat triggering a javascript function automatically

The setInterval function in javascript helps the browser to execute a javascript function repeatedly over a time period and its syntax is as follows

setInterval( myFunction, noOfSeconds*1000) , where

setInterval is the name of the native javascript function
myFunction is the name of your custom function that needs to be triggered repeatedly
noOfSeconds is the time gap in number of seconds after which your custom function needs to be executed again

Once the setInterval is invoked, the stop the same the clearInterval command should be invoked.The syntax of the same is as follows,

clearInterval(myFunction)

No comments:

Post a Comment