Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts

    can't set height of element

    Hi there, I'm using
    Code:
    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, but with no success. It's probably an error in the script, although I tried something more simple like
    Code:
    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).
    Last edited by croatiankid; 04-30-2007 at 09:20 PM.

  • #2
    Banned
    Join Date
    May 2006
    Location
    England
    Posts
    664
    Thanks
    0
    Thanked 84 Times in 84 Posts
    Quote Originally Posted by croatiankid View Post

    x = Element.getHeight('content');

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

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

  • #3
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    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, are there any pointers you could give me?
    Last edited by croatiankid; 04-30-2007 at 10:36 PM.

  • #4
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Is this 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.

    Edit: Opera on works if I delete the if else section. No idea why.
    Last edited by Arbitrator; 05-01-2007 at 02:42 AM. Reason: See the post.
    For every complex problem, there is an answer that is clear, simple, and wrong.

  • #5
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    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!

  • #6
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    nevermind, it works, didn't see you added 100% height to html.
    Last edited by croatiankid; 05-03-2007 at 09:37 AM.

  • #7
    Senior Coder Arbitrator's Avatar
    Join Date
    Mar 2006
    Location
    Splendora, Texas, United States of America
    Posts
    3,300
    Thanks
    28
    Thanked 275 Times in 269 Posts
    Take a look at http://my.opera.com/community/forums....dml?id=187745 for a CSS‐based solution. I posted this there to try and figure out the problem with the script in Opera.
    For every complex problem, there is an answer that is clear, simple, and wrong.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •