Results 1 to 7 of 7

Thread: Script that makes an iframe's height and width adjust to its content

  1. #1
    Join Date
    Jan 2016
    Location
    Norway
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Script that makes an iframe's height and width adjust to its content

    Hi guys.

    I have been searching for hours without luck now

    Do you guys know a script that can make an iframe adjust to the height of its content to avoid a scrollbar. I am currently working on this: https://moneybanker.dk/laaneberegner/, however as you can see if you change month period to eg. "72", the scrollbar will appear - I want to avoid that.


    Anyone here that has knowledge of how to accomplish an iframe that will adjust the height to its content ?

    Best regards and thanks for any tips i can get in advance.

    /Labra
    Last edited by Beverleyh; 01-13-2016 at 10:11 PM. Reason: Formatting

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Google "auto height iframe script" or "iframe resizer script" and try a few out - there are loads.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. #3
    Join Date
    Aug 2004
    Posts
    10,140
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Take a look at the source of this script for some ideas on how to go about getting your IFRAME to automatically adjust to the content contained inside. The content must be from the same domain as the page hosting the IFRAME in order for this technique to work, however.
    DD Admin

  4. #4
    Join Date
    Jan 2016
    Location
    Norway
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Will try them out. Thanks

    Will be back with questions if im not succesfull

  5. #5
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,840
    Thanks
    49
    Thanked 247 Times in 239 Posts
    Blog Entries
    56

    Default

    See this.
    Hitting a links will open an iframe whose height adjusts to its content. This is even true for links inside the iframe. For example, click on mitochondrial DNA then, inside the iframe, on eukaryotic cells.

  6. #6
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    For reference - I used this script on a project recently - works cross-domain and very robust.

    Keep same and cross domain iFrames sized to their content with support for window/content resizing, in page links, nesting and multiple iFrames. (Dependency free, IE8+) — http://davidjbradshaw.github.io/iframe-resizer/
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  7. #7
    Join Date
    Jan 2016
    Location
    Norway
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I tried a few already without luck. I think the reason why its not working is that the source in the iframe is dynamic, in the way that the length change based on user input.

    So i guess i need to (for it to work) create a script that upon keyup triggers the iframe resize script that adjust the height of the iframe.

    I struggle to figure that out ? Any ideas.?

Similar Threads

  1. Conveyor Belt Slideshow - how to adjust height and width of photos, et al
    By Chipster in forum Dynamic Drive scripts help
    Replies: 12
    Last Post: 02-13-2014, 08:57 PM
  2. Adjust IFRAME height within table..
    By krao in forum JavaScript
    Replies: 0
    Last Post: 03-16-2011, 03:49 PM
  3. Replies: 0
    Last Post: 12-14-2010, 04:20 PM
  4. Adjust width but it makes no difference
    By annasue in forum Dynamic Drive scripts help
    Replies: 1
    Last Post: 07-28-2010, 03:16 PM
  5. Iframe height adjust with tabbed content
    By tonypili in forum Dynamic Drive scripts help
    Replies: 4
    Last Post: 10-06-2009, 06:43 AM

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
  •