Jump to content

Help please?


GetReady

Recommended Posts

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
Share on other sites

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.