Get width and height of element

  • Thread starter Thread starter Alejandro Penate-Diaz
  • Start date Start date
A

Alejandro Penate-Diaz

Hi. Is there any way of getting an element real size from javascript, when
this element was previously assigned a width and height of 100%?
Thanks,
Alex.
 
In IE you can use the getBoundingRect() method. Look ut up on MSDN for
documentation and examples. In most cases, you can use offsetHeight and
offsetWidth of the element, like

var e = document.getElementById("myDiv");
alert(e.offsetHeight);
alert(e.offsetWidth);
 
Back
Top