SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2004
    Location
    UK
    Posts
    24
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re-sizing an object via JavaScript ?

    I'm experimenting with a few graphics in seperate DIV's

    Basically I have a left DIV, top DIV, right DIV & center DIV.

    The center has an image set to 100% width and will adjust the page height. I'm trying to scale the left DIV, I can read the height of the image in the center DIV, but the top DIV is text only and IE6 returns "undefined" when I try to read the height property.

    The desired effect is to set the height of the left = top_menu.height + center.height

    This is the javascript

    var objbb_logo = document.getElementById('bbll');
    var objbb_background = document.getElementById('bb');
    var objtop_menu = document.getElementById('top_menu');
    objbb_logo.height = (objbb_background.height);

    the desired is

    objbb_logo.height = (objbb_background.height + objtop_menu.height);

    bb & bbll are ID's associated with and IMG whereas top_menu is an ID assocated with a DIV.

    I guess I'm missing something obvious !

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Most HTMLElements don't have a .height property - it's a (CSS) .style.height, and it may be an empty string, if you've set the height in a global stylesheet, as explained here. The relevant, rendered dimensions in pixels - set via CSS or not - are found at:
    Code:
    ref_to_element.offsetWidth
    ref_to_element.offsetHeight
    Best to do this type of layout with pure CSS if possible.
    ::: certified wild guess :::


Bookmarks

Posting Permissions

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