Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

text clock on JS

Status
Not open for further replies.

hablablow

Programmer
Sep 9, 2000
115
FR
Hello,

I would like to put a simple text clock on a page.
All material i found are clocks in fields, rarely on a layer.
I finally worked with a script that displays text clock in a cell.
Works fine in Msie, not on netscape.
If someone can recommand an Url with a simple text clock in a cell or look at the code below:

<TD BGCOLOR=&quot;#F2FFBF&quot; WIDTH=&quot;100&quot; ID=&quot;clok&quot;> <SCRIPT LANGUAGE=&quot;JavaScript&quot;>
<!-- Begin

function clock() {
if (!document.clok && !document.all) return;
var digital = new Date();
var hours = digital.getHours();
var minutes = digital.getMinutes();
var seconds = digital.getSeconds();
var amOrPm = &quot;am&quot;;
if (hours > 11) amOrPm = &quot;pm&quot;;
if (hours > 12) hours = hours - 12;
if (hours == 0) hours = 12;
if (minutes <= 9) minutes = &quot;0&quot; + minutes;
if (seconds <= 9) seconds = &quot;0&quot; + seconds;

(&quot;<FONT CLASS='fontBody'>&quot;);
dispTime = hours + &quot;:&quot; + minutes + &quot;:&quot; + seconds + &quot; &quot; + amOrPm;
(&quot;</FONT>&quot;);

if (document.clok) {
document.clok.document.write(dispTime);
document.clok.document.close();
}
else
if (document.all)
clok.innerHTML = dispTime;
setTimeout(&quot;clock()&quot;, 1000);
}

// End -->
</SCRIPT></TD>


Do you know why netscape doesn't recognize this and even don't send me a Js error ?

BY the way i would like to apply a certain font style to the text displayed say: fontbody.
I don't know the way to insert this in the write command. This style doesn't work in msie either.

Thanks a lot for your incomming messages.
Habblablow.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top