iframe的自适应高度

来源:互联网 发布:天津财经大学教务网络 编辑:程序博客网 时间:2024/04/30 00:12

<iframe src="right_com.html" id="rightiframe" height="100" name="rightiframe" scrolling="no" frameborder="0"></iframe>

 

<script type="text/javascript"> 

 

function reinitIframe(){
  var iframe = document.getElementById("rightiframe");
  try{
   iframe.height =  iframe.contentWindow.document.documentElement.scrollHeight;
   iframe.width = iframe.contentWindow.document.documentElement.scrollWidth;
  }catch (ex){}
  var iframe = document.getElementById("mainiframe");
  try{
   iframe.height =  iframe.contentWindow.document.documentElement.scrollHeight;
   iframe.width = iframe.contentWindow.document.documentElement.scrollWidth;
  }catch (ex){}
 }
 window.setInterval("reinitIframe()", 200);

 

</script>

原创粉丝点击