How to adjust IFrame height on it's content

http://www.codeproject.com/useritems/Adjust_An_iFrame_Height.asp

<iframe id='myFrame' frameborder=0 scrolling=no width=100%  src="..."
    <EM>onload='adjustMyFrameSize();'</EM>></STRONG> <STRONG>
</iframe>

Then you need to place such script BEFORE IFrame element: </P>

 <script type="text/javascript">
   
    function getElement(aID)
    {
        return (document.getElementById) ?
            document.getElementById(aID) : document.all[aID];
    }

    function getIFrameDocument(aID){
        var rv = null;
        var frame=getElement(aID);
        // if contentDocument exists, W3C compliant (e.g. Mozilla)
        if (frame.contentDocument)
            rv = frame.contentDocument;
        else // bad IE  ;)
            rv = document.frames[aID].document;
        return rv;
    }

    function adjustMyFrameHeight()
    {
        var frame = getElement("myFrame");
        var frameDoc = getIFrameDocument("myFrame");
        frame.height = frameDoc.body.offsetHeight;
    }
</script>

你可能感兴趣的:(content)