0
我发现这里的解决方案 How to auto shrink iframe height dynamically?的iframe自动调整大小增减
我想IFRAME一个论坛,我需要自动调整增加和减少I帧的大小。
现在我有这样的:
<script language="JavaScript" type="text/javascript">
<!--
function autoResize(id){
var newheight;
var newwidth;
if(document.getElementById){
newheight=document.getElementById(id).contentWindow.document .body.scrollHeight;
newwidth=document.getElementById(id).contentWindow.document .body.scrollWidth;
}
document.getElementById(id).height= (newheight) + "px";
document.getElementById(id).width= (newwidth) + "px";
}
//-->
</script>
<iframe frameborder="0" height="200px" id="iframe1" marginheight="0" onload="autoResize('iframe1');" src="/forum" width="100%"></iframe>
但这个代码只增加了尺寸,我也需要减小尺寸。
谢谢。
我发现这里的解决方案:http://stackoverflow.com/questions/20505038/how-to-auto-shrink-iframe-height-dynamically – Snowmane