# I need to auto-adjust IFRAME heights



## pyritechips (Jun 3, 2002)

This is my situation. As shown in the diagram below, I have my webpage set up wherein the default page has only the *banner* section _fixed_. The content is *iframe A*, and as an item is selected from the menu, it is loaded into this frame. The content in *iframe A* is the menu bar and this content does not change.

My problem is that the different pages (items in the menu) all have different heights. I have had to make the two iframe heights = 4000px to make it long enough for my longest page but this leaves long areas of white space when the other shorter pages are loaded.

Is there a way to detect the length of the page being loaded into iframe A and adjust the height value of both iframe A and iframe B accordingly?


----------



## moebius (Oct 7, 2003)

i think this can be done with normal frames and page embedding instead of iframes

u can write a autodetect code in jscript, but thats A LOT OF WORK!!! u need to take in font size consideration, user resolution (Windows API), browser, image sizes, layout, everything... might even be impossible. i suggest embedding 2 frames pages. if u dont know how, ill tell you.


----------



## Corrosive (Jan 9, 2003)

Personally, I would dump the frames and redo the site using CSS positioning. I used the code attached to this post and have done what I presume you want to do.

If you want to know more about CSS Positioning, www.webmonkey.com is great.


----------



## Corrosive (Jan 9, 2003)

Forgot to attach it. D'oh! Try that.


----------



## pyritechips (Jun 3, 2002)

Well, the reason I used frames is a) ease and speed of loading each menu item and b) ease of changing menu content.

The problem is, I have 9 pages each of 800x600 and 1024x768. That's 18 pages, and growing as I add more. When I had the menu on each page I had to change the code on 18 pages. Now with the frames, one menu serves for all the pages. Now when i make a menu change I have to change it only once.

But I will experiment with your css suggestions. i am willing and ready to expand my css knowledge. Thanks for the suggestions and I will let you know how it works out!


----------



## moebius (Oct 7, 2003)

stick with css, but also try hosting your pages from a dynamic webserber (PHP, CGI ASP...) try www.brinkster.com


----------



## Corrosive (Jan 9, 2003)

Or do both. If you need to dynamically update the site, most server-side languages will allow you to code some method of updating the pages. 

Often, this is a password protected "backstage area", or a page where you can use various forms to add, edit or delete stuff. I've mostly seen them written with ASP but PHP and the like should be able to do the same.

If this isn't avaliable, Macromedia's Contribute program is meant to be very handy. It's like a cut down version of Dreamweaver, with areas "lockable" so that inexperienced coders don't mess anything up. I think it costs around £80.

Anyway, have fun


----------



## brendandonhu (Jul 8, 2002)

Sorry Jim, my script from AIM isn't working 
It was telling me the height of all your pages is 418px ::


----------



## pyritechips (Jun 3, 2002)

Thanks for the suggestions but alternate servers and expensive software are not options.

Hello B:

These are the lines from my main page:

*<iframe src ="banner.htm" name="banner" scrolling="no" frameborder="0" width="100%" height="5940">

[/TD]
[TD]
<iframe src ="menu.htm" scrolling="no" frameborder="0" width="100%" height="5940">
*

As you can see I have set the height of the iframes to 5940px, to accomidate my largest page.

I was looking online to get an idea how this can be done with JS and i found this line. I know it mentions an image but is the actual function of any use?


----------



## brendandonhu (Jul 8, 2002)

That looks like its to resize an image to the users resolution. You could resize an iframe too, but I don't think thats quite what you're after.

btw if you need hosting with php, cgi, or whatever PM me


----------

