|
||
| Inside Technique : DHTML Analogue Clock This article explains the principles involved in my DHTML Analogue Clock program. The basic idea of the program is to use DHTML Expressions. DHTML Expressions allow an expression to be assigned to a style for an object. Whenever a variable contained by the expression is changed, the value of the expression changes, and therefore so does the value of the style. For example, if we use an image, and type: <IMG SRC="xyz.jpg" style="position:absolute;left:100;height:expression(x)"> then the image will always be absolutely positioned, and 100 pixels from the left of the browser. The height of the image is governed by the current value of x. So, adding an event handler to the code, say: <IMG SRC="xyz.jpg" onclick="x=Math.floor(Math.random()*300);" style="position:absolute;left:100;top:expression(x)"> which ONLY changes the variable x, also changes the height of the image when the image is clicked.
<HTML>
<HEAD>
<TITLE>Elevator Image</TITLE>
<SCRIPT>
x=100;
</SCRIPT>
</HEAD>
<BODY>
<IMG SRC="xyz.jpg"
onclick="x=Math.floor(Math.random()*300);"
style="position:absolute;left:100;top:expression(x)">
</BODY>
</HTML>
Next we walk you through the script used to create the Analogue Clock. Page 1:DHTML Analogue Clock © 1997-2000 InsideDHTML.com, LLC. All rights reserved. |