[Javascript] height problem, part deux

Chris Basken chriz at basken.com
Mon Apr 30 14:47:46 CDT 2001


> >ready for the kicker?  works fine for width.  pixels, percentages, no
> >problem.  it's just height that's got an issue.
>
> As far as I know NN4 has huge problems with images having a
> height of 100%
> (I tried in tables and they were supposed to be as high as the TD).

yeah, and it looks like NS6 has inherited this problem.  we managed to get
NS4 dropped from the requirements for this project (woo woo!  progress!), so
75% of the madness has dropped away.  still, this height bug remains.

> >so, a question to masters: has anyone come up with a workaround to
> >determine how many pixels an image "really" is when its height
> is dictated
> >as a percentage, in NS?
>
> Try document.images['bar'].offsetHeight in NN6 (maybe it also works in IE
> 5/6), for NN4 you have to place a DIV with position: relative
> around it and
> ask for document.layers['divname'].clip.bottom, which gives the height of
> the DIV (and thus the image).

that's similar to what i just tried, and it seems to work.  specifically, i
have an abs-DIV with a variable height (this is all going into a template,
so the contents of the DIV is dependent on the content for the specific
page), and i need a table behind it to "stretch" so that a TD "fits" the DIV
in terms of height.  so i stuck a rel-DIV at the bottom of the abs-DIV
(inside it, after the included content), then stuck a blank placer image
inside that rel-DIV.  calling the image's .offsetTop value gives me the
bottom of the abs-DIV (relative to the abs-DIV itself), which i can then use
to get the *height* of the abs-DIV.

whew.

in rereading this, i'm wondering if i need the rel-DIV at all...

FWIW, then i'm applying that value to an image in the TD that's supposed to
"stretch" around the DIV.  this forces the TD to grow to the height of the
DIV (which is necessary, because there's more content below that needs to
flow around whatever's inside the abs-DIV).

if any of that made sense, i'll be amazed...  8)





More information about the Javascript mailing list