Title: Javascript Countdown Timer Code and Script Tutorial Guide Javascript Timer
Description: javascript countdown timer code and script tutorial guide javascript timer Javascipt
Tags: javascript, countdown, timer, code, and, script, tutorial, guide, javascript, timer
Info: This Post Has Been Viewed 21448 Times SinceMon Dec 04, 2006 7:40 pm Author bigger_travis With 9 Replies #545

Javascript Countdown Timer Code and Script Tutorial Guide Javascript Timer

This is a simple script that will show you how a countdown timer works with javascript:

to make it work, just do this:

1. copy and paste the code below into your editor, you can use notepad.exe in windows if you don't have a website editor.


     Code:
<p>This simple tutorial code is to show you how javascript can help you display a simple timer, you can get more complicated even if you want to display dates.</p>
<h1 align="center">
<script language="JavaScript">
var countDownInterval=5;
var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
window.location="http://www.wallpaperama.com";
return
}
if (document.all) //if IE 4+
document.all.countDownText.innerText = countDownTime+" ";
else if (document.getElementById) //else if NS6+
document.getElementById("countDownText").innerHTML=countDownTime+" "
else if (document.layers){ //CHANGE TEXT BELOW TO YOUR OWN
document.c_reload.document.c_reload2.document.write('Launching 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('Launching in <b id="countDownText">'+countDownTime+' </b> seconds')
countDown()
}

if (document.all||document.getElementById)
startit()
else
window.onload=startit
setTimeout("location.href='http://www.wallpaperama.com'" , t)
</script>
</h1>
<p align="left">HELP! - If you've found this script helpful, we would appreciate a link to wallpaperama.com. Linking to wallpaperama will make script like this more available to poeple who are looking for help, just like you. Thanks </p>
<p align="center">Script Code at <a href="http://www.wallpaperama.com">Wallpaperama.com </a></p>


2. Once you have copy and paste the code above, save the file as wallpaperama-timer.html

3. After you have saved it, open it with your browser

post picture

4. that's it, if you wan to see it in action, click on the link below where it says demo:

CLICK HERE TO SEE DEMO

Hope this helps
Comments (9)
View Top Comments
Leave Your Comments...
#1
Joao:
3 years ago
#59279
Joao Wed Jun 25, 2008 6:13 am
great stuff but let's imagine if i want 2/3 timers at the same page. what to do?
#2
steve:
3 years ago
#76289
steve Sun Oct 19, 2008 3:22 pm
yes, i was looking for a simple javascript countdown and i found it, thanks
#3
java:
3 years ago
#91506
java Sun Jan 25, 2009 8:47 pm
25-545-javascript-newbie.jpg
you are just amazing man, ive been loooking for something like this and i was able to find it, keep up the good work
#4
tum:
3 years ago
#99815
tum Wed Apr 08, 2009 9:50 pm
amazing for imagine
#5
DJ:
1 year ago
#141643
DJ Wed Aug 11, 2010 3:38 am
Hey buddy,

please get me acode of timer where, it would show (Minute:seconds) format,and will pause the time whenever the browser gets closed or a particular button gets clicked,the next time when the browser gets reopened the page, the time should start from the paused value.
#6
Asim:
1 year ago
#151924
Asim Fri Feb 04, 2011 6:03 am
thanx its working...
#7
izwan:
11 months ago
#158655
izwan Thu Jun 09, 2011 3:47 am
how to disable the link? i just want the timer countdown to zero only.. how?
#8
Usman:
3 months ago
#174521
Usman Sun Jan 22, 2012 9:13 am
22-545-final-preloader.gif
<h1 align="center">
<script language="JavaS
var countDownInterv
var countDownTime=c 1;
function countDown(){
countDownTime-
if (countDownTime <=0){
countDownTime=
clearTimeout(c

return
}
if (document.all) //if IE 4
document.all.c = countDownTime " ";
else if (document.getEl //else if NS6
document.getEl " "
else if (document.layer //CHANGE TEXT BELOW TO YOUR OWN
document.c_rel in <b id="countDownTe countDownTime ' </b> seconds')
document.c_rel
}
counter=setTim 1000);
}

function startit(){
if (document.all|| //CHANGE TEXT BELOW TO YOUR OWN
document.write in <b id="countDownTe countDownTime ' </b> seconds')
countDown()
}

if (document.all||
startit()

</script>
</h1>
#9
amaresh:
1 hour ago
#182993
amaresh Wed May 16, 2012 12:06 am
how do we run the timer code in same web page while we are working with that web page(ex for writing the test)
Leave Your Comments...
Share
| More