Digital Clock : Clock « GUI Components « JavaScript DHTML

JavaScript DHTML
1. Ajax Layer
2. Data Type
3. Date Time
4. Development
5. Document
6. Event
7. Event onMethod
8. Form Control
9. GUI Components
10. HTML
11. Javascript Collections
12. Javascript Objects
13. Language Basics
14. Node Operation
15. Object Oriented
16. Page Components
17. Security
18. Style Layout
19. Table
20. Utilities
21. Window Browser
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
JavaScript DHTML » GUI Components » Clock 
Digital Clock

//Digital Clock - http://www.btinternet.com/~kurt.grigg/javascript

/*
Paste this js-link to where ever you want the clock to appear on your page.

<script type="text/javascript" src="digitalclock.js"></script>


Make sure ALL the images are in a folder/directory called exactly "digital" and 
that it and the digitalclock.js file are in the same folder as the web page using 
the script.
*/

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>

<title>Digital Clock</title>

<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<meta http-equiv="content-script-type" content="text/javascript">
<meta http-equiv="content-style-type" content="text/css">


</head>
<body style="background-color:#000000">


<script type="text/javascript">
//Digital Clock - http://www.btinternet.com/~kurt.grigg/javascript


(function(){

var load_pics = [];
var pics = [];
for(i = 0; i < 12; i++){
 load_pics[i= i+".gif";
}              

for(i = 0; i < load_pics.length; i++){
 pics[inew Image();
 pics[i].src = "digital/"+load_pics[i];
}

var idx = document.images.length;
var get_digit_pos = -1;
var digit_pos = [];
var ini_src = [];
var pic_width = [];

for (i = 0; i < 8; i++){
var comma = (i == || i == 5);

if (!comma){ 
 get_digit_pos++;
}

ini_src[i(comma)?"digital/11.gif":"digital/10.gif";
pic_width[i(comma)?9:16;

digit_pos[i= get_digit_pos;

if (digit_pos[i== digit_pos[i-1]){ 
digit_pos[i"";
}

document.write("<img name='"+idx+"digits"+digit_pos[i]+"' src="+ini_src[i]+" height='21' width='"+pic_width[i]+"' alt=''/>")
}

function digitalclock(){
var x = new Date();
var s = x.getSeconds();
var m = x.getMinutes();
var h = x.getHours();
var the_time = ((h < 10)?"0"+h:h)+''+((m < 10)?"0"+m:m)+''+((s < 10)?"0"+s:s);
for (i = 0; i < the_time.length; i++){
document.images[idx+"digits"+i].src = pics[the_time.charAt(i)].src;
}
setTimeout(digitalclock,100);
}
digitalclock();
})();

</script>

</body>
</html>

           
       
digitalclock.zip( 4 k)
Related examples in the same category
1. JavaScript Clock
2. Fancy Clock
3. JavaScript Clock (2)
4. Live image clock
5. Military Clock
6. Standard Clock
7. Animation: clock
8. Simulates a stop watch and displays the elapsed time
9. Calendar with Clock
w_w__w___.j__a__va2s.___com | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.