GetReady Posted May 5, 2010 Share Posted May 5, 2010 Hi, im newish to javascript, i have some javascript code but would like to run it at the :25 of every hour, is there a code to do this? or a tutorial you can forward me to, ive looked around but one for executing the javascript on that specific time isn't something i can find, Thanks Quote Link to comment Share on other sites More sharing options...
trq Posted May 6, 2010 Share Posted May 6, 2010 If your code was server side you could setup a cron job to execute the task at intervals. The best you could do with javascript is use a timer, but it would all depend on whether or not a user had there browser open. Quote Link to comment Share on other sites More sharing options...
phpchamps Posted May 6, 2010 Share Posted May 6, 2010 You can call a function in javascript after certain period of time by using setTimeout... Below is the example.. Hopefully it will give you a better idea.. and you can achieve what you want to do... <html> <head> <script type="text/javascript"> var c=0; var t; var timer_is_on=0; function timedCount(){ document.getElementById('txt').value=c; c=c+1; t=setTimeout("timedCount()",1000); // 1000 is milisecond } function doTimer(){ if (!timer_is_on){ timer_is_on=1; timedCount(); } } </script> </head> <body> <form> <input type="button" value="Start count!" onClick="doTimer()"> <input type="text" id="txt" /> </form> </body> </html> 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.