开发者

Iframe changing height

开发者 https://www.devze.com 2022-12-18 02:05 出处:网络
I开发者_如何学编程 am trying to get an iframe to automatically resize once a user clicks a link inside of the iframe. How can I do this?You\'ll need to use some Javascript to do this. If you are inter

I开发者_如何学编程 am trying to get an iframe to automatically resize once a user clicks a link inside of the iframe. How can I do this?


You'll need to use some Javascript to do this. If you are interested in making the iframe grow to accommodate the page loaded inside it you can do something like this:

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

the {documentLoaded} can be whatever element you want to draw your height from. on the parent page you add the function

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

a working example with jquery is such:

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

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

精彩评论

暂无评论...
验证码 换一张
取 消