<button class="btn btn-success" id="opener" onclick="ValidateReport('<%=generatecampaign%>','<%=loading_img_path%>','<%=IS_HTML%>','Campaign_Report');">Preview</button>
以上是我的预览按钮
以下是我的 iframe,它在 iframe 中加载一些 html,并使用 html 文件中的数据调整 iframe 的大小,这些数据将在 iframe 中加载
<div class="bordercolor" id="mydiv" style="display: none; text-align: center">
<IFRAME SRC="" id="reportpreview" style="text-align: center; clear:both;"
marginheight="0" frameborder="0" onLoad="sizeFrame();"></iframe>
<iframe id="myIFrm" src="" style="display: none;"> </iframe>
</div>
以上是我的 iframe,它加载 html 文件并根据 html 文件内容调整 iframe 内容的大小......当没有 html 文件时,只需加载一个带有一个标签名称的静态 html 文件为“无可用数据”
我的问题是当我使用 chrome 并且当我想加载 html 文件时。它会自动增加 iframe 10pt 的高度。连续按下预览按钮。但是为什么当我尝试调整 iframe 高度时它不清除以前的高度值...
以下是我在 iframe onLoad 上调用的 javascript 中的 sizeFrame() 函数
function sizeFrame() {
var F=null;
F = document.getElementById('reportpreview');
if(F.contentDocument) {
F.height=0;
F.height = F.contentDocument.documentElement.scrollHeight+10; //FF 3.0.11, Opera 9.63, and Chrome
} else {
F.height=0;
F.height = F.contentWindow.document.body.scrollHeight+10; //IE6, IE7 and Chrome
}
}