方法一:
<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;}
}
</script>
<iframe id="iframepage" src="index.jsp" frameborder="0" width="100%" name="iframepage" scrolling="no" onLoad="iFrameHeight()"></iframe>
方法二:
<script language="javascript" type="text/javascript">
function dyniframesize(down) {
var pTar = null;
if (document.getElementById){
pTar = document.getElementById(down);
}
else{
eval('pTar = ' + down + ';');
}
if (pTar && !window.opera){
//begin resizing iframe
pTar.style.display="block"
if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){
//ns6 syntax
pTar.height = pTar.contentDocument.body.offsetHeight +20;
pTar.width = pTar.contentDocument.body.scrollWidth+20;
}
else if (pTar.Document && pTar.Document.body.scrollHeight){
//ie5+ syntax
pTar.height = pTar.Document.body.scrollHeight;
pTar.width = pTar.Document.body.scrollWidth;
}
}
}
</script>
<table>
<tbody>
<tr>
<td><iframe id="ifm" marginheight="0" src="index01.jsp" frameborder="0" allowtransparency="allowtransparency" name="ifm" marginwidth="0" scrolling="none" οnlοad="javascript:dyniframesize('ifm');" style="min-height: 400px; width: 700px"></iframe></td>
</tr>
</tbody>
</table>