PDA

View Full Version : countdown


carlg
03-15-2005, 07:18 PM
Does anybody have a javascript that I can use for the following scenario :

You will be taken back to our home page in 15 seconds


Where the 15 will countdown to 14, 13, 12, etc. and then take the user back to the home page.


Once I get a JavaScript, how can I call it from the html page?


Thanks for any info

IKLOP
03-15-2005, 09:22 PM
here's the basics of it.

<html>
<head>
<script type='text/javascript'>
var count = 15;

function startCountdown()
{
if( count==0 ){
window.location.href='http://www.homepage.com';
} else {
document.getElementById('countdown').innerHTML=count;
count--;
setTimeout("startCountdown()",1000);
}
}

</script>
</head>

<body onload='startCountdown();'>

You will be redirected in <span id='countdown'>15</div> seconds.

</body>

</html>