...

View Full Version : javascript timer



squish
07-09-2011, 11:24 PM
hi guys, ive found the code for the perfect timer but cant for the life of me find the part to change the date to count down from. can anyone point it out? heres the code.


<script language="JavaScript">
var countDownInterval=5;
var countDownTime=countDownInterval+1;
function countDown(){
countDownTime--;
if (countDownTime <=0){
countDownTime=countDownInterval;
clearTimeout(counter)
window.location="file:///E:/................html";
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){
document.c_reload.document.c_reload2.document.write('WEDDING DAY IN... <b id="countDownText">'+countDownTime+'</b> minutes') </b> seconds')
document.c_reload.document.c_reload2.document.close()
}
counter=setTimeout("countDown()", 1000);
}

function startit(){
if (document.all||document.getElementById)
document.write('WEDDING DAY 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>

jmrker
07-10-2011, 03:46 AM
That is very old code.

document.all only works in MSIE and has been deprecated in favor of document.getElementById
and should be <script type="text/javascript"> rather than the <script> tag you currently have.

You also need to show the HTML portion (or a link to the original code for us to fully help you.

Finally, youl should post your code between [ code] and [ /code] tags (without the spaces)
to make it easier for other forum members to read/analyze.

squish
07-10-2011, 04:49 PM
hi, thanks for the reply, any idea whee i can get a code for a countdown timer? as im not familiar with javascript.

jmrker
07-10-2011, 05:08 PM
hi, thanks for the reply, any idea whee i can get a code for a countdown timer? as im not familiar with javascript.

Have you tried searching this forum
or google with "javascript countdown timer"
See: http://www.google.com/search?q=javascript+countdown+timer&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a

Like: http://javascript.internet.com/time-date/countdown-timer.html
Or; http://forum.codecall.net/javascript-tutorials/22380-how-create-countdown-timer-javascript.html



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum