GuitarGod Posted June 14, 2009 Share Posted June 14, 2009 Hi all, I'm terribly sorry for such a "noob" question, but Javascript isn't my forte. Let's say I have a very simple function. function myfunction() { alert( 'Hi' ); } Is it possible to execute this function every X number of seconds - let's say 3? If so, how? Your help is much appreciated! Quote Link to comment Share on other sites More sharing options...
cs1h Posted June 14, 2009 Share Posted June 14, 2009 Have a look at the settimeout function. This tutorial explains it (I haven't read it so I can't guarantee if it will help but it looks like what you want). http://www.elated.com/articles/javascript-timers-with-settimeout-and-setinterval/ Quote Link to comment Share on other sites More sharing options...
jacksonmj Posted June 14, 2009 Share Posted June 14, 2009 setInterval is better than setTimeout for repeated execution of a function at regular intervals. In this case: setInterval(myfunction,3000); Quote Link to comment Share on other sites More sharing options...
GuitarGod Posted June 14, 2009 Author Share Posted June 14, 2009 Cheers guys Helped me out a lot, thanks. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.