Kód:
<script language="JavaScript" type="text/javascript">
document.write(' Forma1<br /> Magyar Nagydíjig hátralévő idő:<br /><b><div id="winerCountdown"></div></b>');
winerClockCountdown();
function toDateString(strTempString) { strReturnString = ""; if (strTempString < 10) { strReturnString += "0"; } return strReturnString + strTempString.toString(); } function winerClockCountdown() { var strEventDate = new Date("August 06, 2006 14:00:00 GMT+2"); // cl = document.clock; newDate = new Date(); intCount = Math.floor((strEventDate.getTime() - newDate.getTime())/1000); if(intCount <= 0) { return; }
intSeconds = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intMinutes = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intHours = toDateString(intCount % 24); intCount = Math.floor(intCount / 24); intDays = intCount;
document.getElementById("winerCountdown").innerHTML = intDays + " Nap, " + intHours + " Óra, " + intMinutes + " Perc, " + intSeconds + " Másodperc"; setTimeout("winerClockCountdown();", 500); }
</script>
____________________________________________________________________________
Jó tanács:
A Script a Greenwichi Középidőhöz igazodik. (Greenwich Mean Time - GMT) Magyarország +1 időzónához van sorolva. Mivel nyári időszámítás szerint, még +1 órát kell hozzáadni az aktuális időhöz, ezért a kódban télen nyáron állítanod kell az időpontot. (télen GMT+1)
Erről a sorról van szó: var strEventDate = new Date("August 06, 2006 14:00:00 GMT+2");
Két ilyen Script egy oldalon "összekad" és tehát nem működik, ezért a függvények nevét át kell írnod pl. a második Scriptben.
Pl. a második Script így nézzen ki. (a függvények más nevet adtam, hozzáírtam egy kettest.)
<script language="JavaScript" type="text/javascript">
document.write(' Futball Világbajnokság<br> Nyitómérkőzésig hátralévő idő:<br><b><div id="winerCountdown2"></div></b>');
winerClockCountdown2();
function toDateString(strTempString) { strReturnString = ""; if (strTempString < 10) { strReturnString += "0"; } return strReturnString + strTempString.toString(); } function winerClockCountdown2() { var strEventDate = new Date("June 09, 2006 18:00:00 GMT+2"); // cl = document.clock; newDate = new Date(); intCount = Math.floor((strEventDate.getTime() - newDate.getTime())/1000); if(intCount <= 0) { return; }
intSeconds = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intMinutes = toDateString(intCount % 60); intCount = Math.floor(intCount / 60); intHours = toDateString(intCount % 24); intCount = Math.floor(intCount / 24); intDays = intCount;
document.getElementById("winerCountdown2").innerHTML = intDays + " Nap, " + intHours + " Óra, " + intMinutes + " Perc, " + intSeconds + " Másodperc"; setTimeout("winerClockCountdown2();", 500); }
</script>
A hónapok nevét csak angolul fogadja el: January February March April May June July August September October November December |