tags:

views:

46

answers:

1

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?

A: 

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());
Jeremy B.