homepage Welcome to WebmasterWorld Guest from 54.161.147.106
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
5 seconds Countdown scipt
expert_21




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

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.

 

wavebird23




msg:1479865
 3:15 pm on May 16, 2004 (gmt 0)

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!

ArrTu




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

<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>

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved