Click to See Complete Forum and Search --> : javascript clock


poumpoum
12-14-2002, 01:46 PM
Thanx to those who answered my previous thread! Now i need to build a javascript clock using gif images, but not the same way everybody does! I want the clock to display gif images of different sizes instead of displaying the time i.e: "house.gif" instead of the hour etc... --> the picture of a house:the picture of a tree:the picture of a horse :)

David Harrison
12-20-2002, 03:18 PM
This should work. Let me know how you get on.

<html>
<head>

<title>Time & Date</title>

<script language="javascript">

function clock(){
if (!document.layers && !document.all)return;
var digital=new Date();
var hours=digital.getHours();

if(hours>12){hours=hours-12;}

if(hours==1){hours="<img src='house.gif'>"}
else if(hours==2){hours="<img src='tree.gif'>"}
else if(hours==3){hours="<img src='horse.gif'>"}
else{hours="<img src='somethingelse.gif'>"}

if(document.layers){document.write(hours);}
else if(document.all){pictures.innerHTML=hours; setTimeout('clock()', 1000);}}

</script>

</head>

<body onLoad="clock()" bgcolor="#ffffff">

<span id="pictures"></span>

<script language="javascript"><!--Addclock();// --></script>

</body>

</html>