iframe高度自适应内容高度,不出现滚动条怎么解决
低调的可爱 2016-05-11 11:07:40 网上 搜的代码但是不管用,有没有会的人
<div class="fl " id="rbox" style="width: 1180px;">
<iframe id="mainFrame" name="mainFrame" frameborder="0" src="index1.html" scrolling="no" style="height:100%; width:100%;" onLoad="iFrameHeight();">
</iframe>
</div>
<!-------------jieshu--------------->
</div>
</div>
<script>
function iFrameHeight() {
var ifm= document.getElementById("mainFrame");
var subWeb = document.frames ? document.frames["mainFrame"].document : ifm.con;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight;
}
}
</script>