2016-12-27 110 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; 
    } 
});