2014-01-29 73 views
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> 

但這個代碼只增加了尺寸,我也需要減小尺寸。

謝謝。

+0

我發現這裏的解決方案:http://stackoverflow.com/questions/20505038/how-to-auto-shrink-iframe-height-dynamically – Snowmane

回答