Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

mmzplanet

macrumors regular
Original poster
Nov 4, 2004
221
0
Florida
On this site, http://www.austenduncanracing.com, I would like to use the iFrame for the forum that is on the site. But because the length is different for each view (posts, main, calendar, etc) how can I get the iFrame to auto-adjust to the length of the content on the page to avoid the scroll bar in the frame?
 
I used this code to solve the same kind of problem on a website I made. Just be sure to call the setFrameHeight() function from body.onload or where ever is relevant in your code. :)

Code:
<script type="text/javascript">
function setFrameHeight() {
	frame       = window.document.getElementById('forum_iframe_id');
	innerDoc    = (frame.contentDocument) ? frame.contentDocument : frame.contentWindow.document;
	objToResize = (frame.style) ? frame.style : frame;
	if(innerDoc.body)
		objToResize.height = innerDoc.body.scrollHeight+"px";
	else
		objToResize.height  = "100%";
}
</script>
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.