By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,654 Members | 1,575 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,654 IT Pros & Developers. It's quick & easy.

question about style.height

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.