Refresh every minute, on the minute.

D

Denebola

I am trying to refresh my webpage every minute, on the minute and so
far have the script below in the <head> of my page:

<SCRIPT LANGUAGE="JavaScript"><!--
function startTimer() {
var now = new Date();
var minutes = now.getMinutes();
var seconds = now.getSeconds();
setTimeout('refresh()',(((((seconds>0)?1:0)) * 60) + (60 -
seconds)) * 1000);
}

function refresh() {
window.location.href = 'http://www.bbc.co.uk';
}

startTimer();
//--></SCRIPT>

The problem is that if i visit this page at say 25 seconds past the
minute, it won't refresh at the next minute change (in 35 seconds) but
will wait til the next minute to do so (i.e. in 95 seconds).

Where am I going wrong......??

Regards
 
C

Chris Smith

Denebola said:
I am trying to refresh my webpage every minute, on the minute and so
far have the script below in the <head> of my page:

<SCRIPT LANGUAGE="JavaScript"><!--

You want comp.lang.javascript. This is comp.lang.java.programmer.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
S

saryada

Have you tried to use the <META http-equiv refresh>? Here is an
example:

<meta http-equiv="Refresh" content="n;url">

Put this meta tag inside your html <head> tag.

Where n is the number of seconds to wait before refreshing and url is
the url to be reloaded.

Regards,
I Wayan Saryada
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top