PDA

View Full Version : Redirect Count down



Puk
Oct 22nd, 2010, 11:13 AM
Hi,

I want to do a redirect count so that the user can see the count going down. for example, I want them to be able to see the following.

You will be redirected in 5 seconds.

The user should be able to see the count going down from 5 to 4 to 3 to 2 to 1 and then they are redirected.

I can get the page to redirect after 5 seconds but I want the user to be able to see it count down.

Thanks in advance for your help

Philip M
Oct 22nd, 2010, 11:26 AM
Here you are.



<span id = "time"></span>

<script type = "text/javascript">

function display(secs) {
if (secs <= 0) {
window.location = "http://www.google.com";
return false;
}
document.getElementById("time").innerHTML ="You will be redirected in " + secs + " seconds";
secs--;
setTimeout("display("+secs+")",1000);
}

display(5);
</script>

BTW, the time to say "thanks" is afterwards, not beforehand which gives the - doubtless unintended - impression that you take other people's voluntary unpaid assistance and expertise for granted. Or as British politician Neil Kinnock put it, "Don't belch before you have had the meal." Prefer to use "please" beforehand and if you find a response helpful then you can use the "Thank User For This Post" button.


"Dives sum, si non redo eis quibus debeo. - I am a rich man as long as I do not pay my creditors"