View Full Version : Script that makes an iframe's height and width adjust to its content
Labra
01-13-2016, 09:09 PM
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
Beverleyh
01-13-2016, 10:11 PM
Google "auto height iframe script" or "iframe resizer script" and try a few out - there are loads.
ddadmin
01-13-2016, 11:55 PM
Take a look at the source of this script (http://dynamicdrive.com/dynamicindex17/iframessi2.htm) 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.
Labra
01-14-2016, 09:21 AM
Will try them out. Thanks
Will be back with questions if im not succesfull :)
molendijk
01-14-2016, 10:43 PM
See this (mesdomaines.nu/eendracht/iframe_resize_better/demo.html).
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.
Beverleyh
01-15-2016, 06:34 AM
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/
Labra
01-15-2016, 11:58 AM
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.?
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.