Iframes resize problem

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
susanna
Beginner
Beginner
Posts: 4
Joined: Sun Sep 28, 2003 8:33 pm

Iframes resize problem

Post by susanna »

Hi, I find out a problem with IFRAMES, I found out a script which make a iframe resize...

I put the following code inside head tag:

Code: Select all

<script language="JavaScript">
<!--
function resize_iframe()
{
  document.getElementById("iframeprincipal").height=document.body.offsetHeight-document.getElementById("iframeprincipal").offsetTop-43;//resize the iframe according to the size of the window
}
window.onresize=resize_iframe; //this will resize the iframe every time you change the size of the window.
//Instead of using this you can use: <BODY onresize="resize_iframe()">

//-->
</script>
and I put the following code inside body tag:

Code: Select all

<SCRIPT>
function openIFrame(iFrameId,winURL)
{
	ifId=gmobj(iFrameId)
	ifId.src=winURL
}
</SCRIPT>

Code: Select all

<iframe id='iframeprincipal' width=100%  scrolling="auto" frameborder="0" src="coettc.cgi?tolink=_scfmedio">
  <div align="center" class="white12"> 
	Su navegador no soporta iFrames, por favor actualice su navegador para ver correctamente estas páginas. 
  </div>
</iframe>
This script works fine but the iframe size do not change until all the web page contents load completely.

I try to put this:

Code: Select all

onload='resize_iframe()'

on body tag and don't works.

I try to put this:

Code: Select all

onload='resize_iframe()'

on iframe tag and don't works too.

I tried adding:

Code: Select all

<SCRIPT LANGUAGE="JavaScript">
<!--
resize_iframe();
//-->
</SCRIPT>
and milonic menu STOP WORKING!!!...


Please help meee, my web page is http://www.coettc.net, I'm going crazy!!!!!!!!!!!


Thanks in advance.

Susanna
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

You have a TON of stuff going on in that iframe. You have to understand. Once that stuff is all done loading THEN the onLoad event fires...thats why its happening. And the Iframe doesn't know what size it will be to report to the parent until its done loading.

You may want to try changing the default initial height of the iframe in the parent window. Instead of being only, about 200-300 px like it looks like, make it bigger like almost what the page SHOULD be. Then at least it won;t be as noticable.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
Post Reply