December 18, 2000 - Initializing Element Coordinates
![]() |
December 18, 2000 Initializing Element Coordinates Tips: December 2000
Yehuda Shiran, Ph.D.
|
style object's left and top properties. The following strings are example values of the left and top properties: 50px, 32px, and 0px. You can initialize an element properties by the STYLE attribute of its HTML tag. Notice the left:"150px" string in the following tag definition:
<INPUT ID="button1" STYLE="position:relative; left:"250px"; visibility:'visible';" TYPE="button"
VALUE="Show My Visibility" onclick="handleClick1()">
Here is how this button renders:Click the button to check its visibility. It will come out empty for both Internet Explorer and Netscape 6. Surprisingly enough, both Internet Explorer and Netscape 6 do not recognize the string format of the
left and top properties, and position them at coordinates (0,0). To solve this problem, you need to use the integer format:
<INPUT ID="button2" STYLE="position:relative; left:250; visibility:'visible';" TYPE="button"
VALUE="Show My Visibility" onclick="handleClick2()">
and then it will render like this:Notice that only now the button is 250 pixels to right. Click the button to check its visibility. It will come out empty for Netscape 6 and
"visible" for Internet Explorer.


Find a programming school near you