Countdown

D

djflo

Hallo alle zusammen!

Ich hab mal ne Frage, und zwar, wie kann man einen Countdown Zähler machen? Ich will also nur einen einfachen Zähler, der innerhalb von 10 Sekunden von 10 auf 0 runterzählt.
Danke
Flo
 
Code:
<SCRIPT LANGUAGE="JavaScript">


<!--
var g_iCount = new Number();

// CHANGE THE COUNTDOWN NUMBER HERE - ADD ONE TO IT //
var g_iCount = 11;

function startCountdown(){
       if((g_iCount - 1) >= 0){
               g_iCount = g_iCount - 1;
               numberCountdown.innerText = '00:00.0' + g_iCount;
               setTimeout('startCountdown()',1000);
       }
}
//  End -->
</script>

<BODY onLoad="startCountdown()">

<div align="center" id="numberCountdown"></div>

geht doch!:p
 
hmm

wenn du ein crossbrowser-script haben willst würd ich das so machen:

Code:
<html>
<head>
<script language="JavaScript">
var x=10;
var timer;
function countDown() {
if(x!=-1) {
		 if (document.all) {
		 	document.all.blub.innerHTML = x;
		 } else if ((!document.all) && (document.getElementById)) {
		    document.getElementById('blub').innerHTML = x;
		 } else if (document.layers) {
		    document.layers.blub.document.open();
		    document.layers.blub.document.write(x);
			   document.layers.blub.document.close();
	  }
   x--;
   timer=setTimeout("countDown()", 1000);
} else {
   clearTimeout("timer");
   alert("COUNTDOWN beendet!");
}}
</script>
</head>
<body onload="countDown()">
<div id="blub">10</div>
</body>
</html>

so gehts auf allen browsern!

greetZZzz daIllu ;-)
 
Zuletzt bearbeitet:

Neue Beiträge

Zurück