View Full Version : Dynamic Iframe Height Script Help.

11-01-2007, 09:17 PM
1) Script Title: Iframe SSI Script II

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/iframessi2.htm

3) Describe problem:

My problem is that I entered this script into my forum.php page. The iframe does not resize automatically to the height desired.

Can someone tell me if this script is working and/or how to fix it.

my website is: www.ggcorner.info
the forum iframe page is: www.ggcorner.info/forum.php


11-02-2007, 11:48 AM
The iframe height is defined in the js file and it must be possible to use styling of the class. I have tried many places and construction without succes.
<style type="text/css">
#iframe.tabcontentiframe {height:1000px}

I am sure that I am doing some wrong and hope that together with g0d that someone can tell us trhe missing link.


11-02-2007, 08:24 PM
I added the script to my page with the iframe in it. It does not work.
Is there anyone with ideas.

11-02-2007, 09:18 PM
I have an idea, the script you are talking about is finicky when it comes to the markup of both the top page (surrounding the iframe - if the iframe has a container that cannot shrink and grow along with it, like a table cell, certain divisions, etc.) and that of the imported page(s), absolute positioning can be bad, as well as anything (like floats, other dynamic content, etc.) that makes it unclear to the browser what the exact layout height of the page is, or if the page cannot wrap to the width of the iframe.

Before I go into details, if you don't (as is often the case with forums) have a lot of control over the layout of the pages, find some other way to deal with the situation besides this script. The script doesn't work in Opera, and perhaps others, is only rated for IE and FF - and can be, as I say, finicky in those.

11-03-2007, 03:23 AM
I added the script to the .php file using the iframe.
I edited it appropriately to use my iframes name instead of myframe.
What I am trying to do is integrate my forum into an iframe on my website.
I have succesfully done this regarding width but I cannot find a way to set a dynamic height. This is where this script comes into play.

Can someone please tell me what I am doing wrong / any other solution to make the integrated Iframe have a dynamic height?

Thank you. Below is the code from my forum.php page regarding the iframe and the script..

This is the script code in my file:

<script type="text/javascript">

* IFrame SSI script II- Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
* Visit DynamicDrive.com for hundreds of original DHTML scripts
* This notice must stay intact for legal use

//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:
//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:
var iframeids=["forum"]

//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):
var iframehide="yes"

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]
var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers

function resizeCaller() {
var dyniframe=new Array()
for (i=0; i<iframeids.length; i++){
if (document.getElementById)
//reveal iframe for lower end browsers? (see var above):
if ((document.all || document.getElementById) && iframehide=="no"){
var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])

function resizeIframe(frameid){
var currentfr=document.getElementById(frameid)
if (currentfr && !window.opera){
if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax
currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight;
else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax
currentfr.height = currentfr.Document.body.scrollHeight;
if (currentfr.addEventListener)
currentfr.addEventListener("load", readjustIframe, false)
else if (currentfr.attachEvent){
currentfr.detachEvent("onload", readjustIframe) // Bug fix line
currentfr.attachEvent("onload", readjustIframe)

function readjustIframe(loadevt) {
var crossevt=(window.event)? event : loadevt
var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement
if (iframeroot)

function loadintoIframe(iframeid, url){
if (document.getElementById)

if (window.addEventListener)
window.addEventListener("load", resizeCaller, false)
else if (window.attachEvent)
window.attachEvent("onload", resizeCaller)


This is the iframe code:

<td width="608" height="504" valign="top"><center><iframe onload="resize_iframe()" title="forum" id="forum" src="http://www.ggcorner.info/forum" scrolling="auto" frameborder="0" width="613" height="650"></iframe></center></td>

11-04-2007, 04:46 PM
this is pathetic.
obviously there is something faulty with your script and there is absolutely 0 effective support on this forum.
is there no one here with any knowledge on this topic.

11-04-2007, 05:03 PM
Support here is completely based on volunteers who take time to help others.

Getting upset and especially getting angry with us won't do much for your case.

11-04-2007, 06:10 PM
I might add that, personally I don't like the iframe resizing concept because it is so finicky, so it is low on my priority of scripts to help with. Having the person inquiring about it cop an attitude makes me even less inclined to bother with it, though I might get to it if I'm bored and there is little else to do in the forums here. Ajax is generally a better solution if resizing of the display area is required, but can be tricky with paths and scripts on the external pages. If one is willing to do the work, the path and script problems can be dealt with though. However, with an auto resizing iframe, getting it to size as desired isn't always compatible with a given design on the top and/or external page(s), and there can be other issues. It was the best that was available at one point for this type of thing, Ajax has changed that.

11-04-2007, 07:12 PM
I am not angry or upset I am just making a clearly observable comment based on the amount of support here.

Is there any way to fix the current script and to get it to work?
Or is there another alternative solution such as this Ajax thing and could you tell me how to pursue it

11-04-2007, 07:24 PM
Your mood is not transferred through your words; your tone is. Consider making them relate.

The "amount of support here" is great. But in this instance, it isn't necessarily fixing the script in question, because it's boring, hard and not very compatible to begin with.

11-04-2007, 07:37 PM
so is anyone going to help me/point me in the right direction or just leave me hanging?

11-04-2007, 08:26 PM
Tempted at this point to leave you hanging. For a forum, if I'm remembering correctly that's what you are trying to put in the iframe, for what you have planned, the iframe might be best. If you want the right direction though, just let your users nav directly to the forum. It would be so much easier.

Oh, and before you go judging the level of support on this board, check out all the threads and compare the level of support to that given in other free, volunteer forums.

11-04-2007, 09:45 PM
yes, I am trying to put a forum in the iframe.
I have already done all the work and everything functions 100% i just need the iframe height to be dynamic. For some reason last night it started working and now it no longer functions...

11-06-2007, 11:45 PM
help me please