/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Returning height of div in firefox and javascript

Hi all! Can anyone tell me what is the javascript syntax for ascertaining the height and width of a div? I have achieved it in IE (read this: [URL=”http://lists.evolt.org/archive/Week-…09/122159.html”]http://lists.evolt.org/archive/Week-…09/122159.html[/URL]) but it doesn’t work in firefox. I need to know the dimensions when the onload event has fired. The div is dynamically populated with text on the server, so the height is not set at any point.

You can see it working in IE in this test page: [URL=”http://www.josegallardo.net/index3.php”]http://www.josegallardo.net/index3.php[/URL]

I have a master div (‘cuerpo2col’) that should have the larger height of the children divs (‘colcontenido’ and ‘menu’).

Any help would be apreciated ?

to post a comment
CSS

6 Comments(s)

Copy linkTweet thisAlerts:
@ZnupiApr 20.2007 — You shouldn't use IE's proprietary document.all['colcontenido'], and use the W3C-standard document.getElementsById('colcontenido');
Copy linkTweet thisAlerts:
@gallarpriauthorApr 20.2007 — Thanks Znupi for answering. I have tried with document.getElementsById, but it doesn't seems to work ? this is the page with the code: http://www.josegallardo.net/index4.php

Thanks! ?
Copy linkTweet thisAlerts:
@ZnupiApr 20.2007 — Try this, I don't guarantee if it works:
<i>
</i>function jsAjuste(numColumnas) {
var masterdiv = document.getElementById("cuerpo2col");
var contentdiv = document.getElementById("colcontenido");
var menudiv = document.getElementById("menu");

<i> </i>var hcapa1 = contentdiv.offsetHeight;
<i> </i>var hcapa2 = menudiv.offsetHeight;

<i> </i>if ( hcapa1 &gt; hcapa2 ) { masterdiv.style.height = (hcapa1 + 200) + "px"; }
<i> </i>else { masterdiv.style.height = hcapa2 + "px"; }
}
Copy linkTweet thisAlerts:
@gallarpriauthorApr 20.2007 — WOW, now it works !! ? ? ? Thanks Znupi! ?
Copy linkTweet thisAlerts:
@ZnupiApr 20.2007 — Anytime ?. Semi-offtopic: what do you use the 'numColumnas' parameter for? ?
Copy linkTweet thisAlerts:
@gallarpriauthorApr 20.2007 — :p I have 2 versions of the design of the webpage, one version in one column and another in two columns, with this variable I select the height of the correct column ^^

For example, the 2 columns design is: http://www.josegallardo.net

and the 1 column design: http://www.josegallardo.net/cv.php

cheers ^^

Jose.
×

Success!

Help @gallarpri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.23,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...