dcsimg
Results 1 to 4 of 4

Thread: Javascript won't display "height" value?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,857

    Javascript won't display "height" value?

    The below javascript function isn't displaying the "height" value like I need it to. It just displays "undefined". This function is being called from an onclick action and I'm passing the parameter of "this". If I replace "height" with "id", it displays the element id...but not the "height".

    Code:
                function ResizeDiv(obj) {
                    alert(obj.height);
                }
    What I'm trying to do in this function is resize a div. The element being passed is a <details> tag.
    Blake

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,355

    Re: Javascript won't display "height" value?

    <details> uses a clientHeight property.

    Code:
     x = document.getElementById("detailsElement");
      alert(x.clientHeight);
    Slow as hell.

  3. #3
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    CT
    Posts
    17,763

    Re: Javascript won't display "height" value?

    That is one of the reasons to use a library such as jQuery.

    $("#detailsElement").innerHeight()

    or

    $("#detailsElement").outerHeight()

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  4. #4

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    4,857

    Re: Javascript won't display "height" value?

    Thanks guys! Both suggestions work.
    Blake

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width