You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
<script type="text/javascript">
|
|
|
|
var endDate = new Date(2004, 11, 31); // 31.12.2004
|
|
var div_name = 'countdown';
|
|
function update()
|
|
{
|
|
var jetzt = new Date();
|
|
var dif = endDate - jetzt;
|
|
var string = '';
|
|
var x;
|
|
|
|
// Tage
|
|
x = parseInt(dif / 1000 / 60 / 60 / 24);
|
|
string += format(x);
|
|
dif -= x * 1000 * 60 * 60 * 24;
|
|
// Stunden
|
|
x = parseInt(dif / 1000 / 60 / 60);
|
|
string += ':' + format(x);
|
|
dif -= x * 1000 * 60 * 60;
|
|
// Minuten
|
|
x = parseInt(dif / 1000 / 60);
|
|
string += ':' + format(x);
|
|
dif-= x * 1000 * 60;
|
|
// sekunden
|
|
x = parseInt(dif / 1000);
|
|
string += ':' + format(x);
|
|
|
|
var o = document.getElementById ? document.getElementById(div_name) : null;
|
|
|
|
if(o)
|
|
{
|
|
o.firstChild.data = string;
|
|
window.setTimeout('update()', 1000);
|
|
}
|
|
}
|
|
function format(zahl)
|
|
{
|
|
return zahl < 10 ? '0' + zahl : zahl;
|
|
}
|
|
|
|
onload = update;
|
|
|
|
</script>
|
|
<div style="width:15em;background:#000;color:#f00;font-weight:bold;font-family:mono;" id="countdown"> <br>Tage:Stunden:Minuten:Sekunden</div> |