Click to See Complete Forum and Search --> : Digital Clock


Juli
11-19-2003, 05:14 AM
Hello

I wonder if someone can help me please.
I am trying to put the javascript code for the digital clock into my website, normally I would find it no problem at all, but I have just recently put my site into frames. I am finding a problem getting the script to work

I have a top frame and a main frame and the whole thing then has a frameset. Now as this code comes in three parts could someone please kindly hep me and tell me what parts I paste into what frame, as I would like the clock to appear at the very top centre in the top frame. can this be done please?.

Many thanks for your time, much appreciated :)

Here is the code

<HEAD>

<SCRIPT LANGUAGE="JavaScript">
<!-- Original: Ramandeep Singh (ramandeepji@yahoo.com) -->
<!-- Web Site: http://hard-drive.hypermart.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
var dn;
c1 = new Image(); c1.src = "digital-clock/c1.gif";
c2 = new Image(); c2.src = "digital-clock/c2.gif";
c3 = new Image(); c3.src = "digital-clock/c3.gif";
c4 = new Image(); c4.src = "digital-clock/c4.gif";
c5 = new Image(); c5.src = "digital-clock/c5.gif";
c6 = new Image(); c6.src = "digital-clock/c6.gif";
c7 = new Image(); c7.src = "digital-clock/c7.gif";
c8 = new Image(); c8.src = "digital-clock/c8.gif";
c9 = new Image(); c9.src = "digital-clock/c9.gif";
c0 = new Image(); c0.src = "digital-clock/c0.gif";
cb = new Image(); cb.src = "digital-clock/cb.gif";
cam = new Image(); cam.src = "digital-clock/cam.gif";
cpm = new Image(); cpm.src = "digital-clock/cpm.gif";
function extract(h,m,s,type) {
if (!document.images) return;
if (h <= 9) {
document.images.a.src = cb.src;
document.images.b.src = eval("c"+h+".src");
}
else {
document.images.a.src = eval("c"+Math.floor(h/10)+".src");
document.images.b.src = eval("c"+(h%10)+".src");
}
if (m <= 9) {
document.images.d.src = c0.src;
document.images.e.src = eval("c"+m+".src");
}
else {
document.images.d.src = eval("c"+Math.floor(m/10)+".src");
document.images.e.src = eval("c"+(m%10)+".src");
}
if (s <= 9) {
document.g.src = c0.src;
document.images.h.src = eval("c"+s+".src");
}
else {
document.images.g.src = eval("c"+Math.floor(s/10)+".src");
document.images.h.src = eval("c"+(s%10)+".src");
}
if (dn == "AM") document.j.src = cam.src;
else document.images.j.src = cpm.src;
}
function show3() {
if (!document.images)
return;
var Digital = new Date();
var hours = Digital.getHours();
var minutes = Digital.getMinutes();
var seconds = Digital.getSeconds();
dn = "AM";
if ((hours >= 12) && (minutes >= 1) || (hours >= 13)) {
dn = "PM";
hours = hours-12;
}
if (hours == 0)
hours = 12;
extract(hours, minutes, seconds, dn);
setTimeout("show3()", 1000);
}
// End -->
</script>

</HEAD>

<!-- STEP TWO: Insert the onLoad event handler into your BODY tag -->

<BODY onLoad="show3()" bgcolor="#000000">

<!-- STEP THREE: Copy this code into the BODY of your HTML document -->

<img height=21 src="digital-clock/cb.gif" width=16 name=a>

<img height=21 src="digital-clock/cb.gif" width=16 name=b>
<img height=21 src="digital-clock/colon.gif" width=9 name=c>
<img height=21 src="digital-clock/cb.gif" width=16 name=d>
<img height=21 src="digital-clock/cb.gif" width=16 name=e>
<img height=21 src="digital-clock/colon.gif" width=9 name=f>
<img height=21 src="digital-clock/cb.gif" width=16 name=g>
<img height=21 src="digital-clock/cb.gif" width=16 name=h>
<img height=21 src="digital-clock/cam.gif" width=16 name=j>

<p><center>
<font face="arial, helvetica" size"-2">Free JavaScripts provided<br>
by <a href="http://javascriptsource.com">The JavaScript Source</a></font>
</center><p>

<!-- Script Size: 3.36 KB -->
<!-- Script Size: 1.00 KB -->

Thanks again
Cheers
Julie

Pittimann
11-19-2003, 06:00 AM
Hi!

To avoid problems with your documents the easiest way would be, that you post the code of your top frame document or a link to your site. Your problem will then be easily solved...

Cheers - Pit