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

IE clientheight problem

P: n/a
I'm trying to dynamically change the height of a div, and I have it
working in Firefox, but IE isn't letting me get the clientHeight of the
div. When I do an alert to check the clientHeight of the div, it tells
me 0.
Here is the function (at least the part that tries to get the height):

function resizeDivs(divnum){
var branddivid = 'branddiv' + divnum;
var branddiv = document.getElementById(branddivid);
var divheight = branddiv.clientHeight;
alert(divheight);
}

Nov 15 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi Brian,

I recently ran into the same problem... and happily found a solution!
The problem has nothing to do with your code; it's correct. The
problem is that IE only keeps track of "certain" clientHeights...
depending on if the element "has layout". You can read all about it
at:

http://www.satzansatz.de/cssd/onhavinglayout.html

The quick answer to your problem is to make sure the 'branddiv'
elmenents have a 'display: inline-block' style set in them. This will
force the elements to "have layout", which in turn will force IE to
record the elements height.

Good luck!

br********@gmail.com wrote:
I'm trying to dynamically change the height of a div, and I have it
working in Firefox, but IE isn't letting me get the clientHeight of the
div. When I do an alert to check the clientHeight of the div, it tells
me 0.
Here is the function (at least the part that tries to get the height):

function resizeDivs(divnum){
var branddivid = 'branddiv' + divnum;
var branddiv = document.getElementById(branddivid);
var divheight = branddiv.clientHeight;
alert(divheight);
}
Dec 1 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.