View Full Version : can't set height of element

04-30-2007, 10:16 PM
Hi there, I'm using
var y;
if (self.innerHeight) // all except Explorer
y = self.innerHeight - 200;
else if (document.documentElement && document.documentElement.clientHeight)
// Explorer 6 Strict Mode
y = document.documentElement.clientHeight - 200;
else if (document.body) // other Explorers
y = document.body.clientHeight - 200;
var x;
x = Element.getHeight('content');
if (x <= y)
document.getElementById(content).style.height=y + "px";
} here (http://croatiankid.com/services/psd2xhtml), but with no success. It's probably an error in the script, although I tried something more simple like
document.getElementById('content').style.height=5000px; with no effect as well.

Forgot to say: I want the script to expand the #content div so it appears that the footer sticks to the bottom when it's not at that already (if (x <= y)).
The -200 is for circa the height above the #content div, which I'll tweak later (if this script gets running).

Arty Effem
04-30-2007, 11:17 PM
x = Element.getHeight('content');

It's probably an error in the scriptWhich the error console is telling you about:

Error: Element.getHeight is not a function
Source File: http://croatiankid.com/stickyfoot.js
Line: 16

04-30-2007, 11:31 PM
well, how can i get the height of an element (it's not set anywhere, depends on how much text etc). I realize just now that I got that part of the code from a whole js framework.

I've read this (http://www.webmasterworld.com/forum91/4242.htm), are there any pointers you could give me?

05-01-2007, 03:28 AM
Is this (http://www.jsgp.us/demos/CF113329.html) what you want? I adapted some of my code from elsewhere. Works in Firefox 2 and Internet Explorer 6/7. I didnít test it with overflowing text though.

Opera on works if I delete the if else section. No idea why.

05-01-2007, 10:04 AM
Yes, however, I'd like to save quite a bit of the code by just getting the content div's height, minus circa 200px (i'd tweak it later), since all the pages on the site have the same space from the start of the viewport to the container div. this would replace contentMinHeight() it looks like.

also it would not be neccessary to get paddings or borders of it because on each page they're the same, i'd just have it in mind when tweaking the circa 200px that's subtracted from #content's height.

What do you think, would it work, or better to leave as is (opera isn't a problem anyway)? Just trying to save space. And thanks for coding that!

05-01-2007, 10:07 PM
nevermind, it works, didn't see you added 100% height to html.

05-03-2007, 11:49 PM
Take a look at http://my.opera.com/community/forums/topic.dml?id=187745 for a CSS‐based solution. I posted this there to try and figure out the problem with the script in Opera.