首页 > 其他 > 详细

iframe高度自适应

时间:2015-11-07 10:54:40      阅读:195      评论:0      收藏:0      [点我收藏+]

<iframe id="win" height="140" marginheight="0" src="http://www.sdfao.gov.cn/lm/front/main.jsp?sysid=004" frameborder="0" width="100%" name="win" marginwidth="0" scrolling="no" align="top" onload="javascript:document.getElementById(‘win‘).style.height = win.document.body.scrollHeight + 20 + ‘px‘;"></iframe>
<script type="text/Javascript">
 function reinitIframe(){
 var iframe = document.getElementById("win");
 try{
 var bHeight = iframe.contentWindow.document.body.scrollHeight;
 var dHeight = iframe.contentWindow.document.documentElement.scrollHeight;
 var height = Math.max(bHeight, dHeight);
 iframe.height = height;
 }catch (ex){}
 }
 window.setInterval("reinitIframe()", 200);
</script>

iframe高度自适应

原文:http://cag2050.blog.51cto.com/1009647/1710526

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!