日期:2014-05-17  浏览次数:20429 次

急急急!关于iframe的高度问题
我在div里面放一个iframe,div的高度为100%,我希望iframe的高度也是100%,这种方法我试过了<iframe name="rightcontent" scrolling="no" frameborder="0" width="100%" height="100%" ></iframe>这种也不行 onload="this.style.height=this.contentWindow.document.body.scrollHeight",急需各位的帮助。谢谢了!!!

------解决方案--------------------
onload="this.style.height=this.contentWindow.document.body.scrollHeight+'px'"
------解决方案--------------------
iframe里面的网站是你自己的吗?是你自己的才可以。
你可以在iframe页面里面写

<script>
function reSizeframe() {
parent.document.getElementById('iframeID').style.height=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight) + "px";
}
</script>
<body onload="reSizeframe()">


iframe则要加id="iframeID"