[Javascript] Dynamically resizing an iframe

Herzner, Daniel DHerzner at andorcap.com
Thu Nov 29 09:38:34 CST 2001


Hi All, I'm trying to include an iframe on a web page whose source is an
.asp file. I want the frame to be sized dynamically depending upon the size
of its src. The src file will always be a fixed width but the height can
vary quite a bit. I found a technet article that made doing this sound
pretty easy. The article only talks about doing this with an htm file as the
src. Am I having trouble doing this because I'm using an .asp file? The
article includes some javascript:

function reSize()
  {
  	try{	
  	var oBody	=	ifrm.document.body;
  	var oFrame	=	document.all("ifrm");
  		
  	oFrame.style.height = oBody.scrollHeight + (oBody.offsetHeight -
oBody.clientHeight);
  	oFrame.style.width = oBody.scrollWidth + (oBody.offsetWidth -
oBody.clientWidth);
  	}
  	//An error is raised if the IFrame domain != its container's domain
  	catch(e)
  	{
  	window.status =	'Error: ' + e.number + '; ' + e.description;
  	}
  }

and then the html:

<BODY onload=reSize()>
  	<iframe onresize=reSize() id=ifrm src=YOUR_PAGE_HERE></iframe>
</BODY>

So, I'm doing all of this but it's not making a difference to what I'm
trying to achieve. Can someone out there please give me a hand with this?
I've done my homework but still can't see how to pull this off. Thanx in
advance everyone...

Dan Herzner
phn: 203-588-2294
fax: 203-588-2460




More information about the Javascript mailing list