'Jquery - Dynamically resize frame from with in
In using winbox.js
https://nextapps-de.github.io/winbox/ to create iframes and within each I'm loading local php pages which all have jquery available.
The iframe loads to a default size which is what a want, but when I follow a link within an iframe to another local php page I want to resize the iframe so it fits the contents.
I've been able to do it specifying the iframe id, width and height using the following:
$('#winbox-2', window.parent.document).width('900px');
$('#winbox-2', window.parent.document).height('1000px');
But I'd like to do this so it automatically matching the contents size so it's not fixed width/height as above.
Also I need to be able to do this dynamically to the iframe as I won't know what id
each iframe has.
Is there any way to do this ?
Thanks
Solution 1:[1]
Add this to the iframe: ??
onload="$(this).height($(this.contentWindow.document.body).find(\'div\').first().height());"
Answer: https://stackoverflow.com/a/29801343/1510309 From duplicated question: make iframe height dynamic based on content inside- JQUERY/Javascript
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Kip |