Here is the code I use and it displays correctly in IE and FireFox.
==============
<!-- Begin
var timerID = null;
var timerRunning = false;
function stopclock (){
if(timerRunning)
clearTimeout(timerID);
timerRunning = false;
}
function showtime () {
var now = new Date();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds()
var timeValue = "" + ((hours >12) ? hours -12 :hours)
if (timeValue == "0") timeValue = 12;
timeValue += ((minutes < 10) ? ":0" : ":") + minutes
timeValue += ((seconds < 10) ? ":0" : ":") + seconds
timeValue += (hours >= 12) ? " PM" : " AM"
//document.clock.face.value = timeValue;
document.getElementById('clock').innerHTML = timeValue;
timerID = setTimeout("showtime()",1000);
timerRunning = true;
}
function startclock() {
stopclock();
showtime();
}
// End -->
==============
-----Original Message-----
From: Rebecca Wells [mailto:[EMAIL PROTECTED]
Sent: Tuesday, April 05, 2005 11:43 AM
To: CF-Talk
Subject: OT: JavaScript clock problem w/ Firefox
I have a clock javascript that works fine in IE 6.0, but does not
display correctly in Firefox 1.0.2 or Netscape 7.0. Can anyone tell me
what's up here? I've tried googling for tips, but didn't come up with
anything. Here is the script:
In the head section:
<script type="text/javascript">
function clock() {
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
var amOrPm = "AM";
if (hours > 11) amOrPm = "PM";
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = "0" + minutes;
if (seconds <= 9) seconds = "0" + seconds;
dispTime = hours + ":" + minutes + ":" + seconds + " " + amOrPm;
document.getElementById('clock').innerHTML = dispTime;
setTimeout("clock()", 1000);
}
window.onload = Clock;
</script>
Inside the body:
<div id="clock" style="position:absolute;left:100;top:100;"></div>
In Firefox, it displays the time 8 hours ahead, but in IE it shows the
correct system time.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201568
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54