Forum Moderators: open

Message Too Old, No Replies

javascript error on Firefox and Safari for this countdown clock

Can you see what to fix?

         

leafgreen

12:14 am on Feb 2, 2008 (gmt 0)

10+ Year Member



I am using a free script for a countdown clock. According to a couple of users, it doesn't work on Firefox 2.0 nor Safari 3.0. It displays perfectly on IE6 but gives this javascript error:
'document.getElementById(...)' is null or not an object

Can you see the fix for these browsers?
Here's the script:
<script LANGUAGE="JavaScript">

var present;
var future;
var tseconds;
var seconds;
var minutes;
var hours;
var days;
ID=setTimeout("countdown();", 1000);

function countdown()
{
present = new Date();
present = present.getTime() + (60000) + (12 * 60 * 60 * 1000);
future = new Date("April 01 2008 00:00:01");

tseconds = (future - present) / 1000;

days = tseconds /24/60/60;
days = Math.floor(days);
tseconds = tseconds - (days * 24 * 60 * 60);

hours = tseconds /60/60;
hours = Math.floor(hours);
tseconds = tseconds - (hours * 60 * 60);

minutes = tseconds /60;
minutes = Math.floor(minutes);
tseconds = tseconds - (minutes * 60);

seconds = tseconds;
seconds = Math.floor(seconds);

document.getElementById('days').innerText = days;
document.getElementById('hours').innerText = hours;
document.getElementById('minutes').innerText = minutes;
document.getElementById('seconds').innerText = seconds;
ID=setTimeout("countdown();", 1000);
}
</script>

misterjonez

3:17 am on Feb 2, 2008 (gmt 0)

10+ Year Member



yup, maybe include this code on HTML body

<body>
Day <span id="days"></span>¦ <span id="hours"></span>:<span id="minutes"></span>:<span id="seconds"></span>
</body>

daveVk

4:17 am on Feb 2, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



change all "innerText" to "innerHTML"

leafgreen

7:23 am on Feb 5, 2008 (gmt 0)

10+ Year Member



Thank you for your reply, daveVk. It helped me solve the problem.