标签:iframe 高度自适应
<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