• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1415
  • Last Modified:

IFRAME Expanding

I need to create a site using iframes... what I would like the iframe to do is expand based on the content in it and if needed use the scroll bar on the top frame to scroll up and down the page.

The problem arises when I set scrolling to auto, the scroll bar will appear if the content in the iframe is too long. And if I set scrolling to no, the content will get clipped off.
0
JoshDale
Asked:
JoshDale
  • 2
2 Solutions
 
ZvonkoSystems architectCommented:
Check this iframe:

<iframe name="theFrame" src="some.htm" width="100%" onLoad="f=frames.theFrame;f.frameElement.style.height=f.document.body.offsetHeight"></iframe>

0
 
JoshDaleAuthor Commented:
Didn't seem to work. I got an iframe that was 100% wide, but seemed to be the default height.
0
 
dakydCommented:
I think Zvonko's on the right track, but you want to use scrollHeight instead of offsetHeight.  Hope that helps.

<iframe name="theFrame" src="some.htm" width="100%" onLoad="f=frames.theFrame;f.frameElement.style.height=f.document.body.scrollHeight+'px'"></iframe>
0
 
JoshDaleAuthor Commented:
Nice... that was exactly what I was looking for. Now it looks like a regular webpage...

Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now