Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q707 How can I refresh a webpage every 30 mins on the hour and the half-hour?

You are here: irt.org | FAQ | JavaScript | Redirect | Q707 [ previous next ]

It would be easier if it were just every 30 minutes -- you could then just use a META tag to refresh the location. But to refresh on the hour and at half past the hour, you will need JavaScript:

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

function refresh() {
    window.location.href = 'http://www.irt.org/';
}

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

©2018 Martin Webb