jQuery function sometimes doesn't run
<p>I have the following function, basically used to set an iframe height to the height of it's content:</p>

<pre><code>$("#MSOPageViewerWebPart_WebPartWPQ1").load(function()
        {
            var Height = document.getElementById('MSOPageViewerWebPart_WebPartWPQ1').contentWindow.document.body.scrollHeight;

            document.getElementById('MSOPageViewerWebPart_WebPartWPQ1').height = Height;
        });
</code></pre>

<p>The vast majority of the time this will run as expected, but on the odd occasion it will take numerous reloads of the page before it works. Of course trying to debug it is fruitless as it always seems to hit the function and work.</p>

<p>Anyone any idea why it might not work every time?</p>
