Results 1 to 3 of 3

Thread: HELP tricky DIV height from dynamic content div

  1. #1
    Join Date
    Mar 2008
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default HELP tricky DIV height from dynamic content div

    ahhggg

    Ok I have a div in an HTML and the contents of that div is dynamic... a script populates the data inside the div.

    I NEED to get the height of that div with the dynamic content and there seems to be no way I can get this. Below is my code both HTML and Javascript:

    <html>
    <body>
    <div id="mydiv"> ---- in here data is populated using PHP scripting --- </div>

    <script>
    div_height = ocument.getElementById('mydiv').offsetHeight ;
    </script>

    </body>
    </html>



    I tried to use .offsetHeight, .height, .contentHeight and they ALL return a ZERO. Dont forget that the data inside the <div> is populated dynamically so the height of the div will change. Is there any way to get the height of that div after the data gets populated?

    Thank you in advance

    Nate

  2. #2
    Join Date
    May 2007
    Location
    Canada
    Posts
    85
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Don't know if this is just a typo while you were posting it, but you seem to be missing the "d" from the word "document"
    <script>
    div_height = document.getElementById('mydiv').offsetHeight ;
    </script>

  3. #3
    Join Date
    Jan 2007
    Posts
    629
    Thanks
    10
    Thanked 28 Times in 28 Posts

    Default

    You might also try an onload event.
    HTML Code:
       <html>
    <head>
       <script>
          function getdivoffset(){
             div_height = document.getElementById('mydiv').offsetHeight;
          }
       </script>
    </head>
    <body onload="getdivoffset()">
       <div id="mydiv"> ---- in here data is populated using PHP scripting --- </div>
    </body>
       </html>
    It could be executing the script before the div finishes loading.

    Or it could definitely be the missing "d"
    --Jas
    function GreatMinds(){ return "Think Like Jas"; }
    I'm gone for a while, but in the meantime: Try using my FTP script | Fight Bot Form Submissions

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
  •