SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Thread: resizing iFrame

  1. #1
    get into it! bigduke's Avatar
    Join Date
    May 2004
    Location
    Australia
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    resizing iFrame

    I dont want to use scrollbars for an iframe, is there a way to resize the iframe to the content height / width?

  2. #2
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It should be possible. Do you know the size of the content before hand, or do you have to do it on the fly? (The latter is a bit more complex than the former.)

    Also, is the content yours or from another site (the latter case may complicate things)?

  3. #3
    get into it! bigduke's Avatar
    Join Date
    May 2004
    Location
    Australia
    Posts
    847
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its dynamic content, so I don't think there'll be a way to know the content height beforehand, moreover it'll be mostly text.

  4. #4
    SitePoint Aficionado JVLB's Avatar
    Join Date
    Jan 2002
    Location
    N 44 56.537' W 123 3.683'
    Posts
    1,127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think the best way to proceed is to put the content in a div with an id. Then use the clientHeight and clientWidth through getElementById to grab the dimensions of the content and use them to resize the iframe. Note that this will only work with the most recent browsers, so you may wish to test for clientHeight (or clientWidth) and branch to scrollbars if the test fails.

  5. #5
    SitePoint Wizard silver trophy
    Join Date
    May 2003
    Posts
    1,843
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ::: certified wild guess :::


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •