This method takes a method to call, and the time (in milliseconds) to wait. The pattern is simple:
- Have the body onload event call the looping function, like UpdateCycle(). This function manages the cycling.
- Have the looping function call whatever action you want, and the setTimeOut method.
- Implement the action method (in this case SetTime) to do whatever action you need.
You could even make a global variable, increment it in each UpdateCycle, and therefore keep a global counter of how many cycle have passed. You could also have the body onload call an initialization method instead, that method would do start-up initialization, and then call the UpdateCycle method.