PDA

View Full Version : Countdown to refresh page



fdlinda
03-19-2006, 07:49 AM
Script: Refresh page Script
http://dynamicdrive.com/dynamicindex6/refresh.htm

Hi, This script is great but I was wondering how I would go about getting it to display the minutes and seconds? So, instead of saying 110 seconds it would say 1 minute 50 seconds. I tried playing with it myself but ended up breaking the script.. many times :( Any help would be really appreciated!

Twey
03-19-2006, 11:03 AM
document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+(countDownTime / 60)+' <span style="font-weight:normal;">minutes and</span> '+(countDownTime % 60)+'</b> seconds')

document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+(countDownTime / 60)+' <span style="font-weight:normal;">minutes and</span> '+(countDownTime % 60)+'</b> seconds')That ought to do it.
This script needs rewriting, methinks.

fdlinda
03-20-2006, 01:45 AM
Thanks for your help. Unfortunately that didn't seem to work.. it doesn't even show the "minutes and" text.. still only the seconds.

fdlinda
03-20-2006, 02:08 AM
I figured it out! Thanks for your help anyway Twey. Incase anybody needs this later on:

I changed:

document.all.countDownText.innerText = countDownTime+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML=countDownTime+" "

to

document.all.countDownText.innerText = Math.floor(countDownTime / 60)+" minutes and "+(countDownTime % 60)+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML= Math.floor(countDownTime / 60)+" minutes and "+(countDownTime % 60)+" "