2010-07-06 123 views

回答

0
<html> 
<script type="text/javascript"> 
function autoIframe(frameId){ 
try{ 
frame = document.getElementById(frameId); 
innerDoc = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document; 
objToResize = (frame.style) ? frame.style : frame; 
objToResize.height = innerDoc.body.scrollHeight + 10; 
} 
catch(err){ 
window.status = err.message; 
} 
} 
</script> 



<iframe id="tree" name="tree" src="tree.htm" onload="if (window.parent && window.parent.autoIframe) {window.parent.autoIframe('tree');}"></iframe> 

这是一个脚本我保存在我的temlates,它不是我的虽然!但我不记得谁是作者..

做在谷歌搜索返回:

<script language="JavaScript"> 

function calcHeight() 
{ 
    //find the height of the internal page 
    var the_height= 
    document.getElementById('the_iframe').contentWindow. 
     document.body.scrollHeight; 

    //change the height of the iframe 
    document.getElementById('the_iframe').height= 
     the_height; 
    } 
<iframe name="the_iframe" onLoad="calcHeight();" scrolling="no" width="730" id="the_iframe" src="you_page.html" frameborder="0" allowtransparency="true"></iframe> 
相关问题