[thelist] iframe as big as necessary?

Peter-Paul Koch gassinaumasis at hotmail.com
Tue Mar 30 06:02:23 CST 2004



>I have a page on my website (let's call it
>http://www.A.com/default.aspx). I want to include on that page a list of
>links to news articles. I have that list of links as a page hosted on
>another site (call it http://www.B.com/news.aspx). So what I've done is
>to include an iframe on my page on site A, with the src attribute set to
>the URL of my page on site B.
>
>So far so good. The thing is, what I'd really like is for the iframe to
>be as big (= high) as required to accommodate the content of the news
>page. I don't ever want the iframe to display scroll bars, or clip; and
>I don't want the iframe to be waaaay too big either. I want it to be
>just the right size for however big the list of news links happens to
>be. And as the news page is dynamically generated I can't just tweak it
>until it looks right...
>
>So is there any way I can specify that an iframe should be as big as it
>needs to be?

Yes, but not in your case.

What you have to do is find the document.body.offsetHeight of the page in 
the iframe and set the height of the iframe to this value + a little bit 
more. This works fine.

However, since the page in the iframe comes from another server you cannot 
read out the document.body.offsetHeight (or, in fact, anything else).

-------------------------------------------------------------------
ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
http://www.quirksmode.org/
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
------------------------------------------------------------------

_________________________________________________________________
Hotmail en Messenger on the move 
http://www.msn.nl/communicatie/smsdiensten/hotmailsmsv2/



More information about the thelist mailing list