2016-12-27 108 views
0

我使用iframe在我的應用程序中嵌入一個站點並使用iframe resizer庫。獲取iframe中內容的高度使用iframe resizer

<iframe id="iframeContainer" class="iframeContainer" src="mysite.com" width="100%" scrolling="no" ></iframe> 

和代碼腳本

iFrameResize({ 
    log:true, 
    autoResize: true, 
    resizeFrom: 'child', 
    sizeWidth:false, 
    checkOrigin:false, 
    minWidth: 1200,, 
    heightCalculationMethod: "max" 
}); 

我希望得到負荷父頁面後height內容的mysite.com,但我已經想到了一個辦法。

+0

當它跨域時,您無法訪問iframe內部 – charlietfl

回答

0

您可以對此使用resizeCallback。

var iFrameHeight; 

iFrameResize({ 
    log:true, 
    minWidth: 1200, 
    heightCalculationMethod: "max", 
    resizeCallback: function(iFrameData) { 
    iFrameHeight = iFrameData.height; 
    } 
});