Can I resize iframe when page inside changes?

Hi there folks!


I found this page:

Explaining how to have the iframe resize on child page load, but I’m unable to get it to work. Here’s what I’ve got .

In parent page:

Inside head(escapes are for PHP):

<script type='text/javascript'>
        function adjustMyFrameHeight()
            var frame = getElement(\\"comments\\");
            frame.height = document.body.offsetHeight + 60 + \\"px\\"; // add 60 pixels to be safe...
        function getElement(aID)
            return (document.getElementById) ?
            parent.document.getElementById(aID) : parent.document.all[aID];

In the body:

iframe name='comments' src='[/yakety-yak/viewtopic.php?f=2&t=1](' width='100%' frameborder='0' scrolling='no' id='comments'></iframe>

In the child page:

<body onload=&#8221;adjustMyFrameHeight();&#8221; id="phpbb" class="section-viewtopic ltr">

The code seems completely inoperable. Upon initial child page load, the iframe is too small to house it.

Can someone point out what I’ve done wrong or whether there’s a better method of handling this?

Thanks for your time!

Hi there,

One thing springs to mind upon looking at your code:

<body onload=&#8221;adjustMyFrameHeight();&#8221; id="phpbb" class="section-viewtopic ltr">

Here you are using weird quotes. Should be:

<body onload="adjustMyFrameHeight();" id="phpbb" class="section-viewtopic ltr">

If that doesn’t help , could you post a link to the page in question, or enough code that we can reproduce your problem?