помогите пожайлуста исправить код так чтобы когда закончится время таймер снова сам перестартовывал автоматически сначала и так по кругу бы шёл и не останавливался
<head> <script type="text/javascript"> var _currentSeconds=0; var _FontSize=10; var _AnzElm=0; var _timerID=0; function init() { _AnzElm = document.getElementById("Anzeige");} function SchriftGroesse(str_operator) { var newFontSize=0; eval("newFontSize = _FontSize" + str_operator + "1"); _AnzElm.style.fontSize = newFontSize + "em"; _FontSize = newFontSize;} function ResetText() { var h_container = document.getElementById("hr"); var m_container = document.getElementById("min"); var s_container = document.getElementById("sec"); if (!isNaN(parseInt(h_container.value))) { Sekunden = parseInt(h_container.value)*3600; } else { alert("Ungültige Stundenangabe!"); return; } if (!isNaN(parseInt(m_container.value))) { Sekunden += parseInt(m_container.value)*60; } else { alert("Ungültige Minutenangabe!"); return; } if (!isNaN(parseInt(s_container.value))) { Sekunden += parseInt(s_container.value); } else { alert("Ungültige Sekundenangabe!");return; } SetCountdownText(Sekunden); } function StartTimer() { if (_timerID == 0) { ResetText(); _timerID = window.setInterval("CountDownTick()", 1000); } } function ResetTimer() { ResetText();_currentSeconds=0; StopTimer(); } function StopTimer() { if (_timerID > 0) { window.clearInterval(_timerID); _timerID = 0; } } function ContinueTimer() { if (_timerID == 0) { _timerID = window.setInterval("CountDownTick()", 1000); } } function CountDownTick() { if (_currentSeconds <= 0) { StopTimer(); return; } SetCountdownText(_currentSeconds-1); } function SetCountdownText(seconds) { _currentSeconds = seconds; var minutes=parseInt(seconds/60); seconds = (seconds%60); var hours=parseInt(minutes/60); minutes = (minutes%60); var strText = AddNull(hours) + ":" + AddNull(minutes) + ":" + AddNull(seconds); _AnzElm.innerHTML = strText; } function AddNull(num) { return ((num >= 0)&&(num < 10))?"0"+num:num+""; } function MM_goToURL() { var i, args=MM_goToURL.arguments; document.MM_return Value = false; for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'"); } --> </script> <style type="text/css"> <!-- body { font-family: Verdana, Geneva, Arial, helvetica, sans-serif; font-size: 12px; font-weight:bold; text-align:center; background-color: #FFFFFF; color: black; height: 100%; margin: 0px; } .anzeige { width:100%; z-index:0; font-size:10em; font-weight:normal; margin-top:1%; } .button { text-align:center; font-weight:bold; } .input { font-family: Verdana, Geneva, Arial, Helvetica, sans-serif; font-size: 12px; color: #000000; text-align:right; } .controls { border-bottom:1px solid gray; height:30px; margin-top:10px; } .copyright { font-size:9px; color:#999999; font-weight:normal; } .copyright a { color:#999999; text-decoration:none; } .copyright a:hover { color:black; text-decoration:none; } </style> </head> <body onload="init();" onunload="StopTimer();"> <form action=""> <input name="hr" type="text" id="hr" value="1" size="2" maxlength="2" /> h <input name="min" type="text" id="min" value="0" size="2" maxlength="2" /> m <input name="sec" type="text" id="sec" value="0" size="2" maxlength="2" /> s <input class="button" name="reset" type="button" id="reset" value="Reset" onclick="ResetTimer();"/> <input class="button" name="start" type="button" id="start" value="Start" onclick="StartTimer();" /> <input class="button" name="stop" type="button" id="stop" value="Stop" onclick="StopTimer();" /> <input class="button" name="continue" type="button" id="continue" value="Weiter" onclick="ContinueTimer(); " /> Schrift: <input class="button" name="smaller" type="button" id="smaller" value="kleiner" onclick="SchriftGroesse('-');"/> <input class="button" name="bigger" type="button" id="bigger" value="größer" onclick="SchriftGroesse('+');"/> </form> <div class="anzeige" id="Anzeige">01:00:00</div> </body> </html> |
Спасибо огромное всё работает как хотел. Я ещё сверху добавил
<script language="JavaScript"> function uhr() { var Datum = new Date(); var Tag = Datum.getDate(); var Monat = Datum.getMonth()+1; var Jahr = Datum.getFullYear(); var Stunden = Datum.getHours(); var Minuten = Datum.getMinutes(); var Sekunden = Datum.getSeconds(); if (Stunden <10) {Stunden= "0" + String(Stunden);} if (Minuten <10) {Minuten= "0" + String(Minuten);} if (Sekunden <10){Sekunden= "0" + String(Sekunden);} if (Monat <10){Monat= "0" + String(Monat);} if (Tag <10) {Tag= "0" + String(Tag);} document.getElementById("webtodateuhr").innerHTML = Tag + "." + Monat + "." + Jahr + " __ " + Stunden + ":" + Minuten + ":" + Sekunden + " Uhr"; timerID = setTimeout("uhr()",1000)}</script> <div id="webtodateuhr" style="font-size:150%; Color: black;"><p> _ </p></div> <script language="JavaScript">uhr(); </script> |
Подскажите почему в IE сигнал работает (оба варианта) а в Firefox нет
http://learn.javascript.ru/play/ydmMF |
Часовой пояс GMT +3, время: 02:11. |