[Javascript] Get HTML element size
Laurent Muchacho
Laurent.Muchacho at london.virgin.net
Tue Mar 8 04:28:20 CST 2005
Hi Simon,
I will recommend not to use inline style as IE will behave strangely (from
my experiences) and not always return the value.
The properties you are looking for are :
width = document.getElementById('mydiv').offsetWidth
height = document.getElementById('mydiv').offsetHeight
Remember that if you don't define the width to a div it will expand to 100%
of the width of the page.
Laurent
-----Original Message-----
From: Simone Fumagalli [mailto:simone at tomato.it]
Sent: 08 March 2005 09:41
To: javascript at LaTech.edu
Subject: [Javascript] Get HTML element size
Ciao javascript,
How do I get the width and the height of a element in my page ?
Suppose I have this HTML:
<div id="mydiv">
<p>Hello people !!</p>
</di>
with this JS code :
my_element = getElementById("mydiv");
alert (my_element.style.width)
I get an empty string :-(
Suggestions ?
--
Simone - simone at tomato.it
_______________________________________________
Javascript mailing list
Javascript at LaTech.edu
https://lists.LaTech.edu/mailman/listinfo/javascript
More information about the Javascript
mailing list