原文地址:http://www.cnblogs.com/Nbge/archive/2013/06/14/3135697.html
<iframe id="iframepage" name="iframepage" frameborder="0" width="100%" scrolling="no" marginheight="0" marginwidth="0" onLoad="iFrameHeight()"></iframe>
<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>
frameborder 属性规定是否显示 iframe 周围的边框。
width:设置iframe宽度,必须设置。
scrolling 属性规定是否在 iframe 中显示滚动条。
marginheight 属性规定 iframe 的顶部和底部的空白边距,以像素计。
marginwidth 属性规定 iframe 的左边和右边的空白边距,以像素计。
onload:页面结束加载之后触发。