3

I'm trying to use a <object type='text/html' data='/forum'></object> to show a phpbb forum inside a content div with width:800px; min-height:525px;.

The div with normal content is resizing so it is getting longer as the content grows. But the object type only holds the height value and makes a scrollbar. If I set no height or height:auto on the object it does not fully expand to the divContent size. If I set the height or min-height fits, but always makes scrollbars.

How can I make the <object> container auto size as the content is getting longer?

Zach Saucier
  • 24,871
  • 12
  • 85
  • 147
user2931144
  • 147
  • 2
  • 14

2 Answers2

3

As correctly pointed out in comments, you can include your forum inside an iframe.

<iframe src="forum.html" width="100%" id="yourframe"></iframe>

Then you can get div height inside iframe, as shown in this post. And finally, you can use this height to resize iframe, according to its content.

$(document).ready(function() {
    $( "#yourframe" ).on('load', function() { 
        var mydiv = $(this).contents().find("div");
        var h = mydiv.height();
        $(this).height(h);
    });
});
Community
  • 1
  • 1
Giorgio
  • 1,940
  • 5
  • 39
  • 64
2

Thanks both, for pointing in the rigth direction :)

i ended up ofcouse using iframe, thanks Quentin. using the following JavaScript:

function ResizeIframe(id){
  var frame = window.parent.document.getElementById('iframe');
  frame.style.height = frame.contentWindow.document.body.scrollHeight + "px";
 }

and html:

echo "<iframe id='iframe' onload='ResizeIframe(\"iframe\")' src='/forum' style='width:100%; min-height:525px; border:0px; overflow-y:hidden;'></iframe>";

Giorgio > i will look futher into your method. Thanks.

Ted
  • 580
  • 4
  • 22
user2931144
  • 147
  • 2
  • 14