Siema, chcialem stworzyc prosty skrypt ktory odliczalby do weekendu (IMG:
style_emoticons/default/winksmiley.jpg) Niestety nie działa tak jak bym tego chciał -.- Wydaje mi sie ze problem jest z funkcja setTimeout ktora wg. mnie powinna wlaczac funkcje czas od nowa (czyli w sumie cały skrypt) po upływie 1s.
Tutaj kod:
<script LANGUAGE="JavaScript"> <!--
function czas(){
now = new Date()
var godz = now.getHours();
var min = now.getMinutes();
var sec = now.getSeconds();
document.write("<center><br><br>")
if (now.getDay() == 5)
document.write("NIE<br><br>Pozostało:<br>" + Math.floor(23 - godz) + " godzin " + Math.floor(59 - min) + " minut " + Math.floor(59 - sec) + " sekund")
if (now.getDay() == 6)
document.write("<b>TAK!</b>")
if (now.getDay() == 0)
document.write("<b>TAK!</b>")
if (now.getDay() == 1)
document.write("<b>NIE</b><br><br>Pozostało:<br>" + Math.floor(119 - godz) + " godzin " + Math.floor(59 - min) + " minut " + Math.floor(59 - sec) + " sekund")
if (now.getDay() == 2)
document.write("<b>NIE</b><br><br>Pozostało:<br>" + Math.floor(95 - godz) + " godzin " + Math.floor(59 - min) + " minut " + Math.floor(59 - sec) + " sekund")
if (now.getDay() == 3)
document.write("<b>NIE</b><br><br>Pozostało:<br>" + Math.floor(71 - godz) + " godzin " + Math.floor(59 - min) + " minut " + Math.floor(59 - sec) + " sekund")
if (now.getDay() == 4)
document.write("<b>NIE</b><br><br>Pozostało:<br>" + Math.floor(47 - godz) + " godzin " + Math.floor(59 - min) + " minut " + Math.floor(59 - sec) + " sekund ")
document.write("</center>")
setTimeout('czas()',1000);
}
onload=function(){czas();}
//-->
</html
Mam nadzieje ze ktos mi powie co jest nie tak (IMG:
style_emoticons/default/smile.gif) (Dzisiaj jest niedziela i skrypt wyswietla "TAK", problem jest gdy powinien odliczac wiec przestawcie sobie date w windowsie na np. wtorek i zobaczycie o co kaman).
Pozdrawiam.