ayrat9
Новичок
Функция отсчета времени до события на Яваскрипт
В ФФ работает, а ИЕ пишет:
---------------------------------------
error: object doesn't support this property or method
--------------------------------------
Помогите найти ошибку в коде:
<script language="JavaScript">
d = new Date();
d.setFullYear(2005, 11, 29);
d.setHours(20, 0, 36);
st = new Date ();
st.setFullYear(2005, 12, 23);
st.setHours(8, 30, 0);
if (st.getTime() > d.getTime())
{
diff = st.getTime() - d.getTime();
diff = Math.floor(diff/1000);
}
else diff = 0;
function countdown(sec)
{
if (sec > 0)
{
days = Math.floor(sec/(60*60*24));
hours = Math.floor((sec - (days*24*60*60))/(60*60));
mins = Math.floor((sec - (days*60*60*24) - (hours*60*60))/60);
secs = Math.floor((sec - (days*60*60*24) - (hours*60*60)) - (mins*60));
document.getElementById('days').innerHTML=' ' + days + ' ';
document.getElementById('hours').innerHTML=' ' + hours + ' ';
document.getElementById('mins').innerHTML=' ' + mins + ' ';
document.getElementById('secs').innerHTML=' ' + secs + ' ';
sec = sec - 1;
window.setTimeout("countdown(" + sec + ")", 1000);
}
else this.location.reload();
}
</script>
В ФФ работает, а ИЕ пишет:
---------------------------------------
error: object doesn't support this property or method
--------------------------------------
Помогите найти ошибку в коде:
<script language="JavaScript">
d = new Date();
d.setFullYear(2005, 11, 29);
d.setHours(20, 0, 36);
st = new Date ();
st.setFullYear(2005, 12, 23);
st.setHours(8, 30, 0);
if (st.getTime() > d.getTime())
{
diff = st.getTime() - d.getTime();
diff = Math.floor(diff/1000);
}
else diff = 0;
function countdown(sec)
{
if (sec > 0)
{
days = Math.floor(sec/(60*60*24));
hours = Math.floor((sec - (days*24*60*60))/(60*60));
mins = Math.floor((sec - (days*60*60*24) - (hours*60*60))/60);
secs = Math.floor((sec - (days*60*60*24) - (hours*60*60)) - (mins*60));
document.getElementById('days').innerHTML=' ' + days + ' ';
document.getElementById('hours').innerHTML=' ' + hours + ' ';
document.getElementById('mins').innerHTML=' ' + mins + ' ';
document.getElementById('secs').innerHTML=' ' + secs + ' ';
sec = sec - 1;
window.setTimeout("countdown(" + sec + ")", 1000);
}
else this.location.reload();
}
</script>