0

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

Tom
  • 1,436
  • 24
  • 50

1 Answers1

0

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

Kip
  • 478
  • 4
  • 13
  • This doesn't seem to make the iframe any larger. – Tom May 06 '22 at 11:29
  • Do you have a wrapping div inside the content? – Kip May 06 '22 at 11:41
  • A php page is being loaded into the iframe, so it's a full document. – Tom May 06 '22 at 12:20
  • 1
    The duplicated question contains much more information then I can give you at this point. You should search for your solution there. ✌️ – Kip May 06 '22 at 12:27
  • I've got this working after manging to find out the parent iframes id. The only issue is once it has been resized if I try to manually resize it it jumps back the original size. – Tom May 06 '22 at 16:38