IFRAME Expanding

Posted on 2005-05-03
Last Modified: 2008-01-09
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.
Question by:JoshDale
    LVL 63

    Assisted Solution

    Check this iframe:

    <iframe name="theFrame" src="some.htm" width="100%" onLoad="f=frames.theFrame;"></iframe>


    Author Comment

    Didn't seem to work. I got an iframe that was 100% wide, but seemed to be the default height.
    LVL 19

    Accepted Solution

    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;'px'"></iframe>

    Author Comment

    Nice... that was exactly what I was looking for. Now it looks like a regular webpage...


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Javascript: Crash Course

    Javascript is not only emerging as the most important language to know, it's flexibility is unique. With Javascript being deployed on the web, mobile and even the desktop this is the one language that all technologists need to know.

    The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
    Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
    The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now