Digitale Uhr mit Gif-Bildern als Ziffern

Mit diesem JavaScript-Programm von Gordon McComb wird eine digitale Uhr mit Gif-Bildern als Ziffern auf dem Bildschirm sichtbar. Dazu mußt folgendes Javascript-Programm zwischen <HEAD> und </HEAD> eingefügt werden:

<SCRIPT LANGUAGE="JavaScript">
<!--
/* Copyright 1996, by Gordon McComb. All Rights Reserved.
You may use this JavaScript example as you see fit, as long as the copyright notice above is included in your script. This example is from "The JavaScript Sourcebook, forthcoming from Wiley Computer Books. */

var Temp;
setClock();

function setClock()
{
var OpenImg = '<IMG SRC="'+pathOnly(location.href)+'dg' var CloseImg='.gif" HEIGHT=19 WIDTH=17>' Temp = "" now = new Date();
var CurHour = now.getHours();
var CurMinute = now.getMinutes();
now = null;
if (CurHour >= 12)
{
CurHour = CurHour - 12; Ampm = "pm";
}
else
Ampm = "am";
if (CurHour == 0)
CurHour = "12"
if (CurMinute < 10)
CurMinute = "0" + CurMinute
else
CurMinute = "" + CurMinute

CurHour = ""+CurHour;
for (Count = 0;
Count < CurHour.length; Count++)
{
Temp += OpenImg + CurHour.substring (Count, Count+1) + CloseImg
}
Temp += OpenImg + "c" + '.gif" HEIGHT=19 WIDTH=15>'
for (Count = 0; Count < CurMinute.length; Count++)
{
Temp += OpenImg + CurMinute.substring (Count, Count+1) + CloseImg
}
Temp += OpenImg + Ampm + CloseImg }

function pathOnly (InString)
{
LastSlash=InString.lastIndexOf ('/', InString.length-1)
OutString=InString.substring (0, LastSlash+1)
return (OutString);
}

//-->
</SCRIPT>

Dort wo die Uhr im Dokument erscheinen soll, muß folgendes eingefügt werden:

<SCRIPT>document.write(Temp);</SCRIPT>

Beispiel

Zip-File mit allen Gif-Bildern(Ziffern) und dem Beispiel