Forum Moderators: not2easy

Message Too Old, No Replies

Can iframes handle pages that vary in depth?

         

smithaa02

9:31 pm on Jun 21, 2007 (gmt 0)

10+ Year Member



I have a page that will be varying quite a bit in height as it changes, and this page will be included in another page via the iframe. My problem is that I can't seem to ensure that this will fit nicely in the iframe. If the content is longer then my default height I get scrollbars, and if it is shorter, I get a lot of white space.

Any ideas?

DrDoc

9:35 pm on Jun 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To my knowledge -- can't be done.

The iframe resides on the parent page, whereas the child page controls its own styling within its alotted space. The parent can only style the iframe, and has no idea how much content there is on the child page.

londrum

9:31 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



you can resize the iframe with javascript. but it will only work if the page in the iframe is on the same server as the main page. and it has to load the page in first, before resizing the frame.
but, of course, it won't do anything for people with javascript turned off.

if you know php, or some other server side language, you could introduce the iframe page in a div instead, which would automatically resize with the content. you could even use the overflow property in css to make it look like an iframe if you want, complete with scrollbars.

topr8

9:36 pm on Jun 22, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>>if you know php, or some other server side language, you could introduce the iframe page in a div instead

alternatively assuming you control both pages you can test server side one in some way how much content the framed page will have and dynamically make the iframe the correct size before serving the parent page ... quite complex to do i should think, but absolutely possible

Xapti

12:09 am on Jun 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not many reasons to use iframes if you have access to something called server side includes (part of server side scripting, CGI, PHP, asp, etc.), something available from almost all non-free web hosts, including some free ones, and not including some not free ones.

The case where you'd want to use iframes is if you wanted the user to be able to navigate in this little window, without changing the rest of the page.
Another somewhat valid reason, is that it would cache the page, so if it's on multiple pages, it wouldn't take long to load each time. Thing is, with server side includes, the browser will ALSO cache that content too. The only thing that I don't think is cached is the HTML code itself. If you're using proper code, this will almost certainly be in the range of 1-40kb, inefficent code may be larger, but it still may not make a huge difference.

[edited by: Xapti at 12:13 am (utc) on June 23, 2007]