www.webdeveloper.com
Results 1 to 2 of 2

Thread: Problem with my code and iFrame height

  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Problem with my code and iFrame height

    I have been battling on for hours with this problem.

    What I would like to achieve:

    My Website (yes I know it is crap) is working mostly fine all round however I would like to have the Glossary in the side bar to fill the remaining height under the "Featured Website" given the altering sizes of the main text in the middle of the page, and if the main text isn't that long (like on the index) to have a scroll bar in the Glossary in the side bar.

    I.e. the iFrame which holds the glossary in the sidebar wants to be the same height as the "MainContent" cell minus a few pixles.

    My very simple code doesn't do anything, and as you can probably tell by now I am quite new to HTML and javascript:

    Code:
    <script type="text/javascript">
    var iframeHeight = ((document.getElementById('text').offsetHeight) + 'px');
    
    document.getElementById('gloss').style.height = iframeHeight;
    </script/>
    The idea in the code is to set iframeHeight to the text height, and then set the iFrame height to iframeHeight, but nothing happens.

    If I set #gloss to have a height of 2000px in the css file, I get the iFrame with a height of 2000px, so I know the css is working.

    If I try this code, nothing happens:
    Code:
    var iframeHeight = ('2000px');
    
    document.getElementById('gloss').style.height = iframeHeight;
    This is my test index page: http://www.thesteamboatingforum.net/index_10.html

    The #text (the cell containing the main text) has a height of 1000px, hence why it all appears 1/2 way down the screen. The iFrame should be set to 2000px by the script but is evidently not working.

    If anyone can either fix the script or suggest a better idea I would be very grateful.

  2. #2
    Join Date
    Jan 2010
    Location
    Winnipeg, Manitoba, Canada
    Posts
    95
    I would put it right into the tag.
    HTML Code:
    <div id="id" align="left" height="2000px">

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles