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! Link to comment https://forums.phpfreaks.com/topic/162138-solved-a-very-simple-loop/ 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/ Link to comment https://forums.phpfreaks.com/topic/162138-solved-a-very-simple-loop/#findComment-855583 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); Link to comment https://forums.phpfreaks.com/topic/162138-solved-a-very-simple-loop/#findComment-855584 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. Link to comment https://forums.phpfreaks.com/topic/162138-solved-a-very-simple-loop/#findComment-855588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.