View Full Version : Dynamic expanding iframe

01-10-2003, 01:37 AM
i have an iframe on my page, witch is 400Pxi wide and 200pxi high.

I also have a menu, witch points to various images on my server, and all the images have the same width (400pix:)) but not the same height.

My question is:
would it be possiple to open these images in the iframe, and make the iframe dynamicly expand and collapse according to what size image is being shown...
Alll this in order to not having to open the images in new window or refreshing the entire page.

Been searching some hours for a script, but no luck sofar...

regards .

01-10-2003, 02:44 AM
you could do this.

// w/ the function to call the pic

i think, the code can probably be compressed but give it a shot.

01-10-2003, 04:53 PM
Could you maybe post an example on how a working example with that code would look?

01-10-2003, 05:09 PM
This seems to work.

Variable Height IFrame Depending on loaded page.

<SCRIPT language=javascript>

function frm_onload(frmname)
frmname.frameElement.height = frmname.document.body.scrollHeight+20;


<A HREF="img or html link" TARGET=frm>Short page</A>
<A HREF="img or html link" TARGET=frm>Long Page</A>
<IFRAME ID=frm NAME=frm WIDTH=100% LANGUAGE=javascript ONLOAD="return frm_onload(frm)">

01-10-2003, 06:06 PM
Yeah that works just fine.

Thanks for this :)

01-10-2003, 06:31 PM
you're a ****ing genius.

I'm not really one to judge tho... just thought i'd say. This really helped me out

01-11-2003, 02:31 PM
Is there any code you can add to make this script work in NS (7.0+), or is that out of the question since its an Iframe?

01-11-2003, 11:26 PM
can't help u on that one, sorry

01-14-2003, 12:14 AM
what about making this code work for Macs IE4.0+ NS4.0+?? Can anyone have any help? All help is appreciated. Thanks

Or is there a possible work around using layers and divs??