471,122 Members | 1,148 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 software developers and data experts.

IE clientheight problem

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
1 15997
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.

Similar topics

4 posts views Thread by JesusFreak | last post: by
2 posts views Thread by Anette | last post: by
8 posts views Thread by dhtml | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.