Resize iframe on content refresh or update
<p>I have an iframe that I would like to resize to match its contents whenever the contents auto refreshes (every few minutes) or when the user interacts with it.  Although the contents are in the same domain, it would be difficult for me to modify the contents.  Ideally, the iframe would just self adjust to the size of its contents.</p>

<p>Current code that resizes only once:</p>

<pre><code>&lt;iframe id="ganglia-frame" src="ganglia.url" width="100%" height="500%"&gt;
    blah not supported blah
&lt;/iframe&gt;

&lt;script language="Javascript"&gt;
    function setIframeHeight(iframe) {
        if (iframe) {
            var iframeWin = iframe.contentWindow ||
                    iframe.contentDocument.parentWindow;
            if (iframeWin.document.body) {
                iframe.height =
                        iframeWin.document.documentElement.scrollHeight ||
                        iframeWin.document.body.scrollHeight;
            }
        }
    }

    $(window).load(function () {
        setIframeHeight(document.getElementById('ganglia-frame'));
    });
&lt;/script&gt;
</code></pre>

<p>Related question: <a href="http://stackoverflow.com/questions/819416/adjust-width-height-of-iframe-to-fit-with-content-in-it">Adjust width height of iframe to fit with content in it</a></p>
