<iframe id="frame_content" src="iframe_b.html" scrolling="no" frameborder="0" οnlοad="this.height=100"></iframe>
<script type="text/javascript">
function reinitIframe(){
var iframe = document.getElementById("frame_content");
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>
如果只考虑FX和IE,并且,iframe里面内容也不进行DOM操作,那仍然可以用最简单的传统处理方式:
<iframe id="frame_content" src="iframe_b.html" scrolling="no" frameborder="0" οnlοad="this.height=this.contentWindow.document.documentElement.scrollHeight"></iframe>
这问题,我寻找了好多资料,都没这篇讲解的详细