iframe自适应高度(兼容IE 火狐 谷歌)

时间:2023-03-09 02:59:57
iframe自适应高度(兼容IE 火狐  谷歌)

<div id="leamain">

<iframe src="#" marginheight="0" marginwidth="0" frameborder="0" scrolling="no" width="765" height=100% id="iframepage" name="iframepage" onLoad="iFrameHeight()" ></iframe>

<script type="text/javascript" language="javascript">

function iFrameHeight() {

var ifm= document.getElementById("iframepage");

var subWeb = document.frames ? document.frames["iframepage"].document :

ifm.contentDocument;

if(ifm != null && subWeb != null) {

ifm.height = subWeb.body.scrollHeight;

}

}

</script>

</div>