View Full Version : Iframe resizing works....until you throw a <form> in there. Why??

Mar 18th, 2009, 03:34 PM
Hello all and thanks for taking a look at this.

On our webpage, we have an iframe which holds a form with a few inputs and a submit button. Depending on which site section you are in, the Iframe will display a different form. Wanting to keep things looking nice and tidy, I'm using javascript and div tags to auto resize the Iframe according to the height space needed to display all the content in the Iframe.

The problem is, from what we have found, is that when you include a form in the iframe's html (even if it is simply just <form></form>) the iframe will set itself to a locked height, which cuts off some of the form. When I use other html as a test, such as P tags and text but not a form, the iframe/javascript function works, resizing the iframe just as it is supposed to no matter how much or little content i throw in there.

I can't figure out why using simple form tags can throw this off.

One more note...not sure if it matters, but the iframe html tags are called from code behind in an aspx page. The actual display being shown in the iframe is strictly html..not an asp page.

Here is the code Im using to achieve this function:

<script type="text/javascript">
function insertIt()
var _y = document.getElementById('framediv');
var _x = window.frames[0].document.body.innerHTML;
_y.innerHTML = _x

<div id="framediv">
<iframe onload="insertIt();"name="youriframe" src="test.html" width="200"
title="Member login area" frameborder="0" scrolling="no"
marginwidth="0" marginheight="0">