iframe改变高度

时间:2010-01-27 16:38:01

标签: iframe

我正在尝试让iframe在用户点击iframe内的链接后自动调整大小。我怎么能这样做?

1 个答案:

答案 0 :(得分:0)

您需要使用一些Javascript来执行此操作。如果您有兴趣使iframe增长以适应其中加载的页面,您可以执行以下操作:

parent.ResizeFrame({documentLoaded}.height());

{documentLoaded}可以是您想要绘制高度的任何元素。在父页面上添加功能

function ResizeFrame(height) {
    getElementById("elementid").height(height);
}

jquery的一个工作示例是这样的:

function ResizeFrame(height) {
    $("#iframeid").height(height);
}

parent.ResizeFrame($("#fileForm").height());