Countdown läuft falsch
#6
Die Adresse hab ich nimmer... schäm... aber den funktionierenden Code:

<html>
<head>
<title>CountDown-Script</title>
<script language="JavaScript" type="text/javascript">

function CountDown() {
var Tsecond = 0; // Zielsekunden
var Tminute = 0; // Zielminuten
var Thour = 10; // Zielstunden
var Tday = 16; // Zieltag
var Tmonth = 09; // Zielmonat
var Tyear = 2006; // Zieljahr
var howlong = "";

var target = new Date(Tyear, Tmonth-1, Tday, Thour, Tminute, Tsecond);
target = target.getTime();
var now = new Date();
now = now.getTime();
var diff = target - now;

var years = (diff - (diff % 31557600000)) / 31557600000;
diff = diff - (years * 31557600000);
var months = (diff - (diff % 2628000000)) / 2628000000;
diff = diff - (months * 2628000000);
var days = (diff - (diff % 86400000)) / 86400000;
diff = diff - (days * 86400000);
var hours = (diff - (diff % 3600000)) / 3600000;
diff = diff - (hours * 3600000);
var minutes = (diff - (diff % 60000)) / 60000;
diff = diff - (minutes * 60000);
var seconds = (diff - (diff % 1000)) / 1000;

if(seconds > -1) {
if (years != 0)
{
howlong = years+" Jahr";
if (years > 1) howlong = howlong+"e";
}
if (months != 0)
{
howlong = howlong + " " + months+" Monat";
if (months > 1) howlong = howlong + "e";
}
if (days != 0)
{
howlong = howlong + " " + days+" Tag";
if (days > 1) howlong = howlong + "e";
}
if (hours != 0)
{
howlong = howlong + " " + hours+" Stunde";
if (hours > 1) howlong = howlong + "n";
}
if (minutes != 0)
{
howlong = howlong + " " + minutes+" Minute";
if (minutes > 1) howlong = howlong + "n";
}
if (seconds != 0)
{
howlong = howlong + " " + seconds+" Sekunde";
if (seconds > 1) howlong = howlong + "n";
}
setTimeout("CountDown()",1000);
} else {
howlong = "Sie ist da!";
}

document.CountDown.diff.value = howlong;
}
</script>
</head>
<body onLoad="CountDown()">
<form name="CountDown"><table width="450" border="1" cellspacing="0" cellpadding="2">
<tr>
<td width="110">bis zum Fanclubtreffen in Teisendorf</td>
<td><div align="center">
<input type="text" name="diff" size="60">
</div></td>
</tr>
</table>
</form>
</body>
</html>
  Zitieren


Nachrichten in diesem Thema
Countdown läuft falsch - von morle - 21.07.2006, 20:56
[Kein Betreff] - von pattex - 21.07.2006, 21:15
[Kein Betreff] - von morle - 21.07.2006, 21:55
[Kein Betreff] - von morle - 21.07.2006, 23:39
[Kein Betreff] - von pattex - 22.07.2006, 00:08
[Kein Betreff] - von morle - 22.07.2006, 06:37

Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste