iframe 高度自适应完美解决方案

<div id="Wealth">
<iframe id="main" name="main" scrolling="no" src="HTMLPage3.htm" frameborder="0" width="100%"></iframe>
<script type="text/javascript">

function reinitIframe(){

var iframe = document.getElementById("main");
//alert(iframe.innerHTML);

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>
</div>
<a href ="LinkTest.htm" target="main">LinkTest</a>

你可能感兴趣的:(JavaScript)