JavaScript 之 iframe自适应问题---可以用来实现网页局部刷新

1.HTML

<iframe src="index.html" id="iframepage" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" onLoad="iFrameHeight()"></iframe>

2.javascript

<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;
   ifm.width = subWeb.body.scrollWidth;
}  
}  
</script>
原文地址:https://www.cnblogs.com/hqutcy/p/5765410.html