• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1419
  • 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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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