Auto-Length iFrame (Rapidweaver)

Discussion in 'Web Design and Development' started by mmzplanet, Jun 21, 2006.

  1. mmzplanet macrumors regular

    mmzplanet

    Joined:
    Nov 4, 2004
    Location:
    Florida
    #1
    On this site, http://www.austenduncanracing.com, I would like to use the iFrame for the forum that is on the site. But because the length is different for each view (posts, main, calendar, etc) how can I get the iFrame to auto-adjust to the length of the content on the page to avoid the scroll bar in the frame?
     
  2. mmzplanet thread starter macrumors regular

    mmzplanet

    Joined:
    Nov 4, 2004
    Location:
    Florida
  3. wmmk macrumors 68020

    wmmk

    Joined:
    Mar 28, 2006
    Location:
    The Library.
  4. Oryan macrumors 6502a

    Oryan

    Joined:
    Apr 1, 2005
    Location:
    Lincoln, NE
    #4
    I used this code to solve the same kind of problem on a website I made. Just be sure to call the setFrameHeight() function from body.onload or where ever is relevant in your code. :)

    Code:
    <script type="text/javascript">
    function setFrameHeight() {
    	frame       = window.document.getElementById('forum_iframe_id');
    	innerDoc    = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
    	objToResize = (frame.style) ? frame.style : frame;
    	if(innerDoc.body)
    		objToResize.height = innerDoc.body.scrollHeight+"px";
    	else
    		objToResize.height  = "100%";
    }
    </script>
     

Share This Page