Jump to content

Countdown Refresh


UG1234

Recommended Posts

Hi,

 

Can anyone point me too a working example of a 'Countdown Refresh', i have found a few examples on the net however i had trouble integrating them.

 

Basically i want a 5 minute countdown do be displayed before the page refreshes.

 

Thanks for any help in advance

Link to comment
Share on other sites

Thanks for your response.

 

I have now managed to get it working with the following code

 

<script language="JavaScript">

 

//Refresh page script- By Brett Taylor (glutnix@yahoo.com.au)

//Modified by Dynamic Drive for NS4, NS6+

//Visit http://www.dynamicdrive.com for this script

 

//configure refresh interval (in seconds)

var countDownInterval=60;

//configure width of displayed text, in px (applicable only in NS4)

var c_reloadwidth=200

 

</script>

 

 

<ilayer id="c_reload" width=&{c_reloadwidth}; ><layer id="c_reload2" width=&{c_reloadwidth}; left=0 top=0></layer></ilayer>

 

<script>

 

var countDownTime=countDownInterval+1;

function countDown(){

countDownTime--;

if (countDownTime <=0){

countDownTime=countDownInterval;

clearTimeout(counter)

window.location.reload()

return

}

if (document.all) //if IE 4+

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)+" "

else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN

document.c_reload.document.c_reload2.document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')

document.c_reload.document.c_reload2.document.close()

}

counter=setTimeout("countDown()", 1000);

}

 

function startit(){

if (document.all||document.getElementById) //CHANGE TEXT BELOW TO YOUR OWN

document.write('Next <a href="javascript:window.location.reload()">refresh</a> in <b id="countDownText">'+countDownTime+' </b> seconds')

countDown()

}

 

if (document.all||document.getElementById)

startit()

else

window.onload=startit

 

</script>

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.