Welcome to WebmasterWorld Guest from 54.145.209.34

Forum Moderators: open

5 seconds Countdown scipt

   
2:55 pm on May 16, 2004 (gmt 0)

10+ Year Member



Hi, I would like a javascript that is able to display a countdown of 5 seconds. For instance, the user loads a page, A.html, and inside the page, it will display 5, then 4, 3, 2, then 1, 0. How do i go about doing that? thanks.
3:15 pm on May 16, 2004 (gmt 0)

10+ Year Member



Put the following script into your website, be sure to change the target URL from [yoursite.com...] to the page that you want the user to be redirected to:
______________________________________________________
<form name="redirect">
<center>
<font face="Arial"><b>You will be redirected to the new page in<br><br>
<form>
<input type="text" size="3" name="redirect2">
</form>
seconds</b></font>
</center>

<script>
<!--
//change below target URL to your own
var targetURL="http://www.yoursite.com"
//change the second to start counting down from
var countdownfrom=5

var currentsecond=document.redirect.redirect2.value=countdownfrom+1
function countredirect(){
if (currentsecond!=1){
currentsecond-=1
document.redirect.redirect2.value=currentsecond
}
else{
window.location=targetURL
return
}
setTimeout("countredirect()",1000)
}

countredirect()
//-->
</script>
______________________________________________________
I hope this script can help you out!

9:44 pm on May 29, 2004 (gmt 0)

10+ Year Member



<HTML>
<HEAD><TITLE>detect and redirect</TITLE>

<SCRIPT LANGUAGE="JavaScript">
var start=new Date();
start=Date.parse(start)/1000;
var counts=10;
function CountDown(){
var now=new Date();
now=Date.parse(now)/1000;
var x=parseInt(counts-(now-start),10);
if(document.form1){document.form1.clock.value = x;}
if(x>0){
timerID=setTimeout("CountDown()", 100)
}else{
switch(screen.width)
{
case 800: goToPage('medres.php'); break;
case 1024: goToPage('hires.php'); break;
}

function goToPage(url)

{
document.location.replace(url);
alert('your screen setting is '+screen.width+'x'+screen.height+', redirecting for optimal viewing');

}
}
}

</script>
<SCRIPT LANGUAGE="JavaScript">
window.setTimeout('CountDown()',100);
</script>

</HEAD>
<BODY BGCOLOR="black" >

<FORM NAME="form1">
In

<INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10">

seconds the page will auto detect your screen resolution for optimal viewing. If you are NOT redirected, you can view our site by clicking <A href="medres.htm">HERE</A><P>

</FORM>

</BODY>

</HTML>

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month