Друзья такая проблема. Есть скрипт таймера
document.getElementsByTagName("body")[0].onload=setTimer;
function setTimer()
{
var maxDays = 3;
var time = "00:00:00";
var now = new Date();
var date=now.getDate();
var year=now.getFullYear();
var month=now.getMonth()+1;
if (month==12) month=0;
switch(month) {
case 0:month="January";break
case 1:month="February";break
case 2:month="March";break
case 3:month="April";break
case 4:month="May";break
case 5:month="June";break
case 6:month="July";break
case 7:month="August";break
case 8:month="September";break
case 9:month="October";break
case 10:month="November";break
case 11:month="December";break
}
var daysReal=date%maxDays;
var FullDate=year+","+month+",1";
var endOfTimer = new Date(FullDate);//05:00:00"); "Jun,12,2013,"+
var ms = (endOfTimer.getTime()-now.getTime());
daysReal= Math.floor(ms/(1000*60*60*24));
if (ms>1)
{
var sec=(parseInt(ms/1000));
var days=(parseInt(sec/(24*60*60)));
var secInLastDay=sec-days*24*3600;
var hours=(parseInt(secInLastDay/3600));
var secInLastHour=secInLastDay-hours*3600;
var minutes=(parseInt(secInLastHour/60));
var lastSec=secInLastHour-minutes*60;
document.getElementById('d').innerHTML = daysReal;
document.getElementById('h').innerHTML = ((hours<10)?(hours="0"+hours): hours);
document.getElementById('m').innerHTML = ((minutes<10)?(minutes="0"+minutes): minutes);
document.getElementById('s').innerHTML = ((lastSec<10)?(lastSec="0"+lastSec): lastSec);
var daysStr = "дня";
if(days==0 || days >= 5) daysStr = "дней"; else if(days==1)daysStr="день";
var hourStr = "часов";
if((hours>=2 && hours<=4) || hours>=22) hourStr="часа"; else if(hours==1 || hours==21) hourStr='час';
var minStr="минут";
if(minutes%10==1 && Math.floor(minutes/10)!=1) minStr="минута"; else if ((minutes%10>=2 && minutes%10<=4) && Math.floor(minutes/10)!=1) minStr="минуты";
var secStr ="секунд";
if(lastSec%10==1 && Math.floor(lastSec/10)!=1) secStr="секунда"; else if ((lastSec%10>=2 && lastSec%10<=4) && Math.floor(lastSec/10)!=1) secStr="секунды";
document.getElementById('ds').innerHTML = daysStr;
document.getElementById('hs').innerHTML = hourStr;
document.getElementById('ms').innerHTML = minStr;
document.getElementById('ss').innerHTML = secStr;
setTimeout("setTimer()",1000);
}
setTimeout("setTimer()",1000);
}
подключаю на страницу все работает, но так грузит браузер через минуту что он виснет... посмотрел в процессах (800мб оперативки занимает и растет...)
Кто может помочь? Заранее спасибо!
Вот html
<div id="timer">
<table width="237" height="73px" border="0" class="center_me">
<tr>
<td id="d" class="blueDigit">2</td>
<td id="h" class="blueDigit">23</td>
<td id="m" class="blueDigit">54</td>
<td id="s" class="redDigit">55</td>
</tr>
<tr class="timeWords">
<td id="ds">дня</td>
<td id="hs">часов</td>
<td id="ms">минут</td>
<td id="ss">секунд</td>
</tr>
</table>
<p class="center_me"></p>
</div>