Purchase Advertising On AWT
 Upload & Sell Your Software
 Upload & Sell Your eBook
 Enter The AWT Control Panel  Contact Applied Web Tools
 Sell Your eBook @ The PDF Store  Password Troubles? Click Here!
Knowledge Center
Want to write for Applied Web Tools? Send your Writer's Query to
Editor@AppliedWebTools.net for details.
HTML
Reference
&
Tutorial
CSS
Reference
&
Tutorial
DOM
Reference
&
Tutorial
JavaScript
Reference
&
Tutorial
50+ Programming Examples
Use HTML, CSS, DOM & JavaScript Together
Misc. Essays & Documents
You'll Find Just About Anything In Here
50+ Web Page Constructions
Learn the Art of Using HTML, CSS, DOM & JavaScript Together
 Changing Background Colors
 Event Triggering With onLoad
 Disabling The Right Click
 DOM Driven Color Changing
 Switching Images
 innerHTML Attribute Access
 Change With innerHTML
 Changing Positions
 Change Position With onMouseMove
 Change Text Position
 Interactivity Skills
 Type-writing A Message
 Auto-changing Text Size
 Making Text Scroll
 Blinking Text
 Simple Form Authentication
 Change Background Color Of An INPUT
 Change Text Color Of An INPUT
 Change Background Image Of An INPUT
 Select All Checkboxes
 Select Color Of The Submit Button
 Change Text Color Of A Submit Button
 Insert Background Image To A Button
 Change Color Of Drop Down List
 Change Text Color Of A Drop Down List
 Change Color Of A TEXTAREA
 Change The Text Color Of A TEXTAREA
 Insert An Image Into A TEXTAREA
 Change The Size Of An Image
 Change The Source Of An Image
 Change The Position Of An Image
 Change The Background Image
 Moving Images Around The Page
 Drag & Drop An Image
 A Simple Image Viewer
 A Shaking Image
 A Digital Clock
 Drop Down List Link
 Top Drop Down Menu
 Always On Top Menu
 Inset Border Buttons
 A Description Generating Menu
 An Image Generating Menu
 A Horizontal Sliding Menu
 A Click Horizontal Sliding Menu
 Returning Cursor Co-ordinates
 Making Text Follow The Cursor
 Attaching An Image To The Cursor
digital clock

Clocks are everywhere, and so they should be in your web page. You can make them as prominent or discreet as your taste allows. In this example, we’re displaying 10 images as the digits of the clock. Each digit is a unique image that is preloaded into an array. We then display the images in increments of a second, minute, or hour.

<html>
<head>

<script type="text/javascript">
function getDigits() {
num=new Array("0.gif","1.gif","2.gif","3.gif","4.gif","5.gif","6.gif","7.gif","8.gif","9.gif");
time=new Date();
hour=time.getHours()
if (hour<10) {
document.getElementById('hour1').src=num[0];
h2="'" + hour + "'";
h2=h2.charAt(1);
document.getElementById('hour2').src=num[h2];
} else {
h1="'" + hour + "'";
h1=h1.charAt(1);
document.getElementById('hour1').src=num[h1];
h2="'" + hour + "'";
h2=h2.charAt(2);
document.getElementById('hour2').src=num[h2];
}

minute=time.getMinutes();

if (minute<10) {
document.getElementById('minute1').src=num[0];
m2="'" + minute + "'";
m2=m2.charAt(1);
document.getElementById('minute2').src=num[m2];
} else {
m1="'" + minute + "'";
m1=m1.charAt(1);
document.getElementById('minute1').src=num[m1];
m2="'" + minute + "'";
m2=m2.charAt(2);
document.getElementById('minute2').src=num[m2];
}

second=time.getSeconds();

if (second<10) {
document.getElementById('second1').src=num[0];
s2="'" + second + "'";
s2=s2.charAt(1);
document.getElementById('second2').src=num[s2];
} else {
s1="'" + second + "'";
s1=s1.charAt(1);
document.getElementById('second1').src=num[s1];
s2="'" + second + "'";
s2=s2.charAt(2);
document.getElementById('second2').src=num[s2];
}
}

function showTime() {
timer=setTimeout("getDigits()",10);
interval=setInterval("getDigits()",1000);
}

function stopInterval() {
clearTimeout(timer);
clearInterval(interval);
}
</script>
</head>

<body onload="showTime()" onunload="stopInterval()" bgcolor="#000000">

<img id="hour1" />
<img id="hour2" />
<img id="minute1" />
<img id="minute2" />
<img id="second1" />
<img id="second2" />

</body>
</html>


It looks a little more complicated than it actually is. The images are placed in an array. The date is read using the getSeconds(), getMinutes() and getHours() methods. We then simply increment those values according to the seconds, minutes and hours we state in increments of milliseconds. For each increment in milliseconds, the appropriate image is displayed from the array we preloaded.
I do not employ cookies or tracking devices of any kind