iframe高度自适应

来源:互联网 发布:ios软件不受信任 编辑:程序博客网 时间:2024/06/06 04:08

JS文件

<script type="text/javascript">    function setIframeHeight(iframe)    {        if (document.getElementById)        {            if (iframe && !window.opera)            {                if (iframe.contentDocument && iframe.contentDocument.body.offsetHeight)                    iframe.height = iframe.contentDocument.body.offsetHeight;                else if(iframe.Document && iframe.Document.body.scrollHeight)                    iframe.height = iframe.Document.body.scrollHeight;            }        }    }    </script>

ifram引用

<iframe id="show" frameborder="0" name="show" onload="setIframeHeight(this)" scrolling="no" src="<%=url %>" width="590px"></iframe>


原创粉丝点击