July 9, 2000 - HTC-Master Focus/Blur Events | WebReference

July 9, 2000 - HTC-Master Focus/Blur Events

Yehuda Shiran July 9, 2000
HTC-Master Focus/Blur Events
Tips: July 2000

Yehuda Shiran, Ph.D.
Doc JavaScript

One of the most frustrating deficiencies of scripting a DHTML element is that you must initialize its STYLE before you can set or modify it during a script. Suppose you have the following DIV element:

<DIV ID="oSun"><IMG SRC="planet.gif"></DIV>

And at some point during your script you want to set the position of the above DIV element. You would probably write something like:

oSun.style.left = 50;
oSun.style.top = 70;

You try to run it and nothing comes up on the screen. The reason? The STYLE tag has not been defined for the above DIV element. Defining the STYLE is straightforward:

<STYLE>
.block {position: absolute; top: 100; left: 100}
</STYLE>

Once the style parameters are predefined, you can modify them via the script, as shown above.