<!-- 报表DIV -->
<div id="reportDiv" style="height:auto;width: 100%">
<iframe id="reportIframe" height="500px" width="100%" onLoad="iFrameHeight()" style="background:#fafafa" valign="top" frameborder="NO" border="0" framespacing="0"></iframe>
</div>
<script type="text/javascript" language="javascript">
function iFrameHeight() {
var ifm= document.getElementById("reportIframe");
var subWeb = document.frames ? document.frames["reportIframe"].document : ifm.contentDocument;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight + 100;
}
<div id="reportDiv" style="height:auto;width: 100%">
<iframe id="reportIframe" height="500px" width="100%" onLoad="iFrameHeight()" style="background:#fafafa" valign="top" frameborder="NO" border="0" framespacing="0"></iframe>
</div>
<script type="text/javascript" language="javascript">
function iFrameHeight() {
var ifm= document.getElementById("reportIframe");
var subWeb = document.frames ? document.frames["reportIframe"].document : ifm.contentDocument;
if(ifm != null && subWeb != null) {
ifm.height = subWeb.body.scrollHeight + 100;
}
}
注解:IFRAME标签追加事件onLoad 调用脚本高度自适应函数、从而实现自适应 加100的意思是高度增长100 防止自适应出现滚动条