本文实例讲述了JS实现iframe自适应高度的方法。分享给大家供大家参考,具体如下:
<iframe id="mainFrame" name="mainFrame" src="/zwgk/hsearchview" width="740" frameborder="0" scrolling="no" scrolling="no" frameborder="0" > </iframe>
<script type="text/javascript" language="javascript"> function reinitIframe(){ var iframe = document.getElementById("mainFrame"); try{ var bHeight = iframe.contentWindow.document.body.scrollHeight; var dHeight = iframe.contentWindow.document.documentElement.scrollHeight; var height = Math.max(bHeight, dHeight); iframe.height = height; }catch (ex){} } window.setInterval("reinitIframe()", 100); </script>
希望本文所述对大家JavaScript程序设计有所帮助。
更多JS实现iframe自适应高度的方法示例相关文章请关注PHP中文网!