Iframe 高度自适应

          <script language="javascript" type="text/javascript">

        function iframeAutoFit(iframeObj) {

            setTimeout(function () {

                if (!iframeObj) return;

                iframeObj.height = (iframeObj.Document ? iframeObj.Document.body.scrollHeight : iframeObj.contentDocument.body.offsetHeight);

            }, 200)

            document.getElementById('tr-iframe').style.display = 'block';

        }

    </script>

  <table border="0" cellpadding="0" cellspacing="0" width="100%">

            <tr id='tr-iframe' style='display: none'>

                <td>

                    <iframe allowtransparency="true" src="" frameborder="0" height="100" width="100%"

  style='background-color:transparent;filter:alpha(opacity=100);'     scrolling="no" align="center" id="frameid" name="framename" onload="javascript:iframeAutoFit(this)"

                        vspale="0"></iframe>

                </td>

            </tr>

        </table>

 

        function SetWinHeight(obj) {

            var win = obj;

            if (document.getElementById) {

                if (win && !window.opera) {

                    if (win.contentDocument && win.contentDocument.body.offsetHeight)

                        win.height = win.contentDocument.body.offsetHeight;

                    else if (win.Document && win.Document.body.scrollHeight)

                        win.height = win.Document.body.scrollHeight;

                }

            }

        }

 

你可能感兴趣的:(iframe)