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 Link to comment https://forums.phpfreaks.com/topic/200847-help-please/ 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. Link to comment https://forums.phpfreaks.com/topic/200847-help-please/#findComment-1053922 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> Link to comment https://forums.phpfreaks.com/topic/200847-help-please/#findComment-1053971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.