2013-02-11 39 views
0
<button class="btn btn-success" id="opener" onclick="ValidateReport('<%=generatecampaign%>','<%=loading_img_path%>','<%=IS_HTML%>','Campaign_Report');">Preview</button> 

以上就是我的預覽按鈕鉻爲什麼每次增加iframe的高度與10px的時候IFRAME負荷?

以下是我的iframe whhich加載一些HTML中的iframe,並與將在IFRAME被加載在HTML文件中的數據調整的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文件中,並調整iframe中的內容爲每個HTML文件內容...並在沒有HTML文件,然後只是簡單地加載一個標籤名一個靜態的html文件作爲「無可用數據」

我的概率是

LEM是當我使用鉻,當我要加載的HTML file..it automaticaly增加IFRAME 10PT的高度。汽車無上按下預覽button.but當我嘗試調整iframe的高度爲什麼它不清除以前的高度值...

以下是在JavaScript我sizeFrame()函數調用上的iframe的onLoad

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 

    } 

    } 

回答

1

首先需要在默認情況下重置iframe:

iframe {margin:0;填充:0; border:0; font-size:100%;字體: 繼承; vertical-align:baseline; }

2

使用CSS重置並重置iframe的值。
喜歡的東西iframe{ margin:0 padding:0 height:0 width:0}。我曾經有過噩夢般的體驗,其中web-kit瀏覽器增加了幾個像素來爲滾動條創建空間。從那時起,我開始在我的項目中使用正確的css-reset,即使它增加了開銷。