iframe自适应高度问题

<iframe src="index.html" id="iframe" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" onLoad="iFrameHeight()"></iframe>
<script type="text/javascript" language="javascript">   
  function iFrameHeight() {   
    var ifm= document.getElementById("iframe");   
    var subWeb = document.frames ? document.frames["iframe"].document : ifm.contentDocument;//(document.frames检测是否是ie,ie下document.frames["iframe"].document,其他为ifm.contentDocument)   
    if(ifm != null && subWeb != null) {
       ifm.height = subWeb.body.scrollHeight;
       ifm.width = subWeb.body.scrollWidth;
    }   
  }   
</script>
posted @ 2014-10-24 18:09  天涯行者  阅读(145)  评论(0编辑  收藏  举报