/    Sign up×
Community /Pin to ProfileBookmark

Firefox version of style.height

Well, there I was, casually redesigning my website, when “BAM!” And then some.

I found myself needing to dynamically change the height of an object to equal the height of the document. I’ve found the height of the document, and I’ve set it up so that IE uses its rather handy document.element.style.height method to get things done.

HOWEVER, as I’m sure you know, Firefox doesn’t have that particular method, at least word for word. So my question is this: Is there – and if there is, what is – a suitable replacement for document.element.style.height?

I have tried both “document.defaultView.getComputedStyle(element,null).getPropertyValue(height),” and “borderleft.offsetHeight,” only to find that they were woefully inadequate and lazy, and that they would only get the value of the current height, not change it.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@Mr_MooSep 05.2007 — Firefox has style.height, you must, however, provide a unit.
<i>
</i>document.getElementById("id_of_element").style.height = newHeight + "px";

IE just assumes you mean pixels.
Copy linkTweet thisAlerts:
@felgallSep 05.2007 — All recent browsers support style.height provided that you identify the units. If you don't specify units then some browsers will guess attometres and some will guess lightyears. Only IE guesses pixels.
Copy linkTweet thisAlerts:
@GazokauthorSep 05.2007 — Arg, now I feel stupid.

Just permit me to save some of my thoroughly injured pride in saying that I [i]did[/i] add + "px," but only to "document.defaultView.getComputedStyle(element,null).getPropertyValue(height)," and "borderleft.offsetHeight," and then forgot that I hadn't used it in style.height >_<
×

Success!

Help @Gazok 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.26,
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,
)...