MyBB Community Forums

Full Version: dynamic iframe height
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
hi all,

i included my forum through an iframe, something like:

<iframe src="mybb/index.html" ...... height="1000px"></iframe>

now the iframe has scrollbars or not depending on height of the forum. the forum height differs (view single postings or view subforum listing), which means the iframe is half empty or is not enough and therefor has scrollbars.

how can i dynamically adapt this iframe depending on current forum height??


thanks!
Some Easy JavaScript should do it Smile

Put this in your header tag:

<script language="JavaScript">
<!--
function resize_iframe()
{

	var height=window.innerWidth;//Firefox
	if (document.body.clientHeight)
	{
		height=document.body.clientHeight;//IE
	}
	//resize the iframe according to the size of the
	//window (all these should be on the same line)
	document.getElementById("webid").style.height=parseInt(height-
	document.getElementById("webid").offsetTop-8)+"px";
}

// this will resize the iframe every
// time you change the size of the window.
window.onresize=resize_iframe; 

//Instead of using this you can use: 
//	<BODY onresize="resize_iframe()">


//-->
</script>

inside your page body, put this:

<iframe src="mybb/index.html" id="webid" width="100%" onload="resize_iframe()"></iframe>

hope that helps Smile
thanks, i ve tried but it doesnt work. the iframe is still to small. it covers only one third of the required space...... sorry
(2011-05-13, 09:53 AM)kenny1313 Wrote: [ -> ]thanks, i ve tried but it doesnt work. the iframe is still to small. it covers only one third of the required space...... sorry

remove the width from the iframe and then try it & see if it works Smile


so just simply try it like this:

<iframe src="mybb/index.html" id="webid" onload="resize_iframe()"></iframe>

if it still doesn't work then do you mind posting a print screen? please & thank you Smile
sorry, the problem still remains. now the height is again too small, didnt change from last try but the width is now too small...

the width was ok with 100%.....

i still have absolute height in pixel, which works somehow but doesnt look too nice..... thx for your help anyway, which is further appreciated :-))
here is a crazy thought, why don't you also try to add the height:

<iframe src="mybb/index.html" id="webid" onload="resize_iframe()" width="100%" height="100%"></iframe>

It should work actually. I don't know why its not working cause on my website, its working Toungue
sorry none of that functions.... i dont know why. i tried......... i want to get rid of iframes.

meanwhile i tried

<?php
ini_set('allow_url_fopen','1');
include ("http://www.xxxxxxxxxxxx.de/mybb/");
?>

or


<?php
include ("http://www.xxxxxxxxxxx.de/mybb/");
?>

to do the same without iframes. now i get:


Warning: include() [function.include]: URL file-access is disabled in the server configuration in /mnt/web7/40/11/51277011/htdocs/test.php on line 46

Warning: include(http://www.xxxxxxxxxxx.de/mybb/) [function.include]: failed to open stream: no suitable wrapper could be found in /mnt/web7/40/11/51277011/htdocs/test.php on line 46

Warning: include() [function.include]: Failed opening 'http://www.xxxxxxxxxxx.de/mybb/' for inclusion (include_path='.:/opt/RZphp5/includes') in /mnt/web7/40/11/51277011/htdocs/test.php on line 46
i managed to get it going: i fixed php.ini

and included the following:

<?php
include ("http://www.xxxxxxx.de/mybb/");
?>

now the forum is shown properly with enough space to avoid scrollbars but not to much to shw empty space.

the only problem (after that its perfect...) is that the links of the forum create a new page without my menu

with iframes the site looked like this

STATIC Part (menu and stuff like that)
*******iframe********
dynamic forum (with differung height)
*******/iframe********

now it looks like

STATIC Part (menu and stuff like that)
*******include********
first forum page
*******/include********

when i now click a link, may opening a thread only the thread with nothing else is shown. no menu.....

any idea how i can open new links of the included forum withou losing the other content (menu and so on...)????

i would appreciate your help a last time, then the tutorial is complete :-))








Why exactly would you want to load the forum in this way...?? Why do you need this sort of method at all??
(2011-06-04, 11:40 AM)MattRogowski Wrote: [ -> ]Why exactly would you want to load the forum in this way...?? Why do you need this sort of method at all??

I'm going to go with he wants to include it in a predesigned webpage so he doesn't have to make a MyBB theme.
Pages: 1 2