[HELP] Automatic Height Contentbox

Discussion in 'PHP' started by HabboCafe, Oct 19, 2010.

  1. #1
    Hello everyone,

    I have a problem, i wanted a contentbox (sliced) that gets longer when the page in the frame is longer then the contentbox.
    I hope someone gets that sentence, i created this code:

        <div id="middle">
        <div id="content_header"></div>
        <div class="content_box">
          <script type="text/javascript">
    
    //<![CDATA[
    window.onload = function() {
    var f = document.getElementById("mainframe");//Sets iframe id
    function resize() { //Starts resize function
    var h = "#";
    var w = "#";
    if (f.contentDocument) {
    h = f.contentDocument.documentElement.offsetHeight + 100 + "px";
    // can't find anything for Opera and Firefox that works for the width. OffetWidth doesn't work right either.(f.contentDocument.documentElement,"").getPropertyValue("width");
    } else if (f.contentWindow) {
    h = f.contentWindow.document.body.scrollHeight + 10 + "px";
    } else {
    return;
    }
    f.setAttribute("height",h);
    f.parentNode.setAttribute("height",h);
    }
    if (window.addEventListener) {
    f.onload = resize;
    } else if (f.attachEvent) {
    f.attachEvent("onload", resize);
    } else {
    return;
    }
    resize(); //starts resize function that was coded further up the code
    }
    //]]>
            </script>
          <iframe name="content_box" id="content_box" src="home.htm" width="100%" frameborder="0" allowtransparency="yes" scrolling="yes" border="0"></iframe>
          <br />
        </div>
        <div class="content_bottom"><br>
        </div>
        </div>
    Code (markup):
    Can someone please tell me what i'm doing wrong or what's wrong.
    It's a really important code for my website. Thanks ;)

    Nathan
     
    Last edited: Oct 19, 2010
    HabboCafe, Oct 19, 2010 IP
  2. HabboCafe

    HabboCafe Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Please give me a answer.. Pleaassee ty btw
     
    HabboCafe, Oct 20, 2010 IP
  3. guardian999

    guardian999 Well-Known Member

    Messages:
    376
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #3
    guardian999, Oct 20, 2010 IP
  4. silviuks

    silviuks Peon

    Messages:
    43
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There are some jquery plugins that do what you want.
     
    silviuks, Oct 21, 2010 IP