469,600 Members | 2,367 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,600 developers. It's quick & easy.

question about style.height

Hi, all

If I didn't set the height of an html element on a web page with html
attributes. Then obj.style.height always reports "0" even after the page has
completely rendered. Is there any way to get the actual height after being
rendered?

Jack
Jul 23 '05 #1
1 4210
Ron
datactrl wrote:
Hi, all

If I didn't set the height of an html element on a web page with html
attributes. Then obj.style.height always reports "0" even after the page has
completely rendered. Is there any way to get the actual height after being
rendered?

Jack

The following code will get the computed height in pixels:

var obj = document.getElementById("myObject");
var objHeight = null;
if(document.implementation.hasFeature("CSS", "2.0")) {
objHeight = document.defaultView.getComputedStyle(obj,
null).getPropertyCSSValue("height").getFloatValue( 5);
}
else if(obj.clientHeight!=null) {
objHeight = obj.offsetHeight;
}

Learn more about the W3C CSS interfaces at
http://www.w3.org/TR/DOM-Level-2-Style . IE's offsetHeight property was
found at
http://msdn.microsoft.com/workshop/a...fsetheight.asp
..
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Greg | last post: by
1 post views Thread by Brian Wilson | last post: by
5 posts views Thread by amerar | last post: by
33 posts views Thread by amerar | last post: by
1 post views Thread by amerar | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.