Hi@all
Ich murks jetzt schon einige Zeit an nem Countdown, der beginnend von jetzt an in 1 Std und 30 min abläuft.
Ich krieg des einfach nicht hin. Countdowns zu einem vorgegbenen Zeitpunkt is kein Prob. Aber wie kann ich mein Script umschreiben, das die Zeit in 1,5 Std. abläuft?
ICh hoffe mir kann da geholfen werden.
LG IGOR72
Ich murks jetzt schon einige Zeit an nem Countdown, der beginnend von jetzt an in 1 Std und 30 min abläuft.
Ich krieg des einfach nicht hin. Countdowns zu einem vorgegbenen Zeitpunkt is kein Prob. Aber wie kann ich mein Script umschreiben, das die Zeit in 1,5 Std. abläuft?
Code:
<html>
<head>
<title>CountDown-Script</title>
<script language="JavaScript" type="text/javascript">
function CountDown() {
var Tsecond = 30; // Zielsekunden
var Tminute = 30; // Zielminuten
var Thour = 14; // Zielstunden
var Tday = 16; // Zieltag
var Tmonth = 3; // Zielmonat
var Tyear = 2005; // 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 = "Ziel erreicht!";
}
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="100">Ziel erreicht in:</td>
<td><div align="center">
<input type="text" name="diff" size="50">
</div></td>
</tr>
</table>
</form>
</body>
</html>
ICh hoffe mir kann da geholfen werden.
LG IGOR72