jaymc Posted September 28, 2007 Share Posted September 28, 2007 Is there a way to use setInterval() without it calling the function at the start, and then how ever many seconds later So for instance this will execute do() every 10 seconds, however, when the page is loaded it wil lexecute then execute again 10 seconds later and so on. When the page is loaded I want it to load do() for the first time after 10 seconds... setInterval(do(), 10000) Quote Link to comment Share on other sites More sharing options...
RichardRotterdam Posted September 28, 2007 Share Posted September 28, 2007 mootools has a function called periodical. http://docs.mootools.net/Native/Function.js[/ulr] scroll all the way down I think that's exactly what you need. Quote Link to comment Share on other sites More sharing options...
nogray Posted September 28, 2007 Share Posted September 28, 2007 mootools use setInterval too for their periodical function, you can do it using setTimeout instead and calling the function on load. function do(){ do something .... setTimeout("do()", 10000); } do(); Quote Link to comment Share on other sites More sharing options...
jaymc Posted September 29, 2007 Author Share Posted September 29, 2007 mootools use setInterval too for their periodical function, you can do it using setTimeout instead and calling the function on load. function do(){ do something .... setTimeout("do()", 10000); } do(); That wouldnt work either The problem is... its an AJAX refresh, however, when the page is first loaded I use PHP to include the file I want refreshing From then on, I want javascript to recall the file ever 10 seconds.. The problem is.. when I use PHP to originally include the first load of the file.. the file is processed Then, when the do(); kicks in from the javascript, ir immediately requests the file, and then again every 10 seconds What I need the javascript to do is not do anything at all for 10 seconds, rather than do it when do() is called and then every 10 seconds..? Quote Link to comment Share on other sites More sharing options...
emehrkay Posted September 29, 2007 Share Posted September 29, 2007 mootools use setInterval too for their periodical function, you can do it using setTimeout instead and calling the function on load. function do(){ do something .... setTimeout("do()", 10000); } piggy backing off of this do window.onload = function(){ setTimeOut('do();', 10000); } 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.