Why this clock isn't good only with NE 4
this code is from Netscapes JavaScript documentation at www.netscape.com
| function
showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() var timeValue = " " + ((hours >23) ? hours -23 :hours) timeValue += ((minutes < 10) ? "h0" : "h") + minutes document.clock.face.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } |
this code works well only with netscape 4
| unction
showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() hours = ((hours>23) ? hours -23 :hours); timeValue = ((hours > 10) ? hours: " " + hours); timeValue += ((minutes < 10) ? "h0" : "h") + minutes document.clock.face.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } |
this code works well with all browsers
| function
showtime () { var now = new Date(); var hours = now.getHours(); var minutes = now.getMinutes(); var seconds = now.getSeconds() hours = ((hours>23) ? hours -23 :hours); timeValue = ((hours > 10) ? hours: "0 " + hours); timeValue += ((minutes < 10) ? "h0" : "h") + minutes document.clock.face.value = timeValue; timerID = setTimeout("showtime()",1000); timerRunning = true; } |
It is because netscape 4 include first space of the string for
centering (it's not consonant with HTML)