无废话,网上很多文章一下写了几种实现方式,代码短点的呢用不了,长点的呢眼睛都看花
下面的代码在火狐、IE上正常
<script type="text/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()", 200); </script>
转载自http://www.jb51.net/article/26132.htm,Mark