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?
Asked
Active
Viewed 273 times
0
-
http://stackoverflow.com/questions/153152/resizing-an-iframe-based-on-content – Sampson Jan 27 '10 at 16:44
1 Answers
0
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.
- 9,168
- 3
- 45
- 57