[Javascript] Get HTML element size

Simone Fumagalli simone at tomato.it
Tue Mar 8 04:13:35 CST 2005


Ciao Richard,
in data martedì 8 marzo 2005, alle ore 11.07, hai scritto:


RL> On Tue, 8 Mar 2005 10:41:29 +0100, "Simone Fumagalli" <simone at tomato.it>
RL> said:
RL> note that getElementById() by itself shouldn't work; you should have
RL> document.getElementById().

Yes, sorry,
I just forgot to write it in the mail. but I have it in my code.

RL> I think that the style properties retrievable via JavaScript are only
RL> those which have been explicitly set:
RL> given:
RL> <div id="mydiv" style="top:5px;left:5px;width:100px;height:20px">
RL>      <p>........</p>
RL> </div>
RL> the script:
RL> my_element = document.getElementById("mydiv");
RL> alert (my_element.style.width)
RL> will return the string "100px".

and actually this works for me too.
The point is that I have some elements with a variable size
and that's why I want to know the width and the height of them.

I can't belive this is not possible.

Simone




More information about the Javascript mailing list