Simple Timer in javascript

28 Dec , 2008  

This tutorial shows you a simple count down timer in javascript, which you can modify according to your need.. This is in javascript, hence it is not as powerful as it should be, like if a user refreshes its browser, the value is not stored anywhere, and the countdown timer start again.

But for the added security you can store the time span in a cookie or a session variable using PHP or anyother web scripting language.

For now the javascript code is like this.

<script language='javascript'>
 var milisec=0
 var seconds=30
 var minutes=1
function display(){
 if (milisec<=0){
 if (seconds<=-1){
 document.getElementById('t1').innerHTML="Time Over";

this is the function display you can paste the above piece of code in the head section of your HTML page. The HTML page may contain the following lines of code.

<body onLoad="display()">
<div id='t1'>

This is a simple, code and you can change it to make it more powerful and attractive,
Note: This is an old post from my another blog, if you face any problem running the code, please report !!
Cheers !!
Realin !


One Response to “Simple Timer in javascript”

  1. Cristophe says:

    Freezes at 0.58.9 ! O.o’

More in javascript, tutorials (100 of 114 articles)

In this tutorial i am going to explain how can we hide or unhide elements on a webpage using simple ...