3.0.0

Is there any way to adjust Iframe height dynamically?

Is there any way to adjust Iframe height dynamically based on the page height inside the Iframe, Please let me know.
Kalpana Aravabhumi
January 25,
The only way that I have found to do that (assuming there are other things on the page beside the IFrame), is to put it in a TR/TD that has it's height set to *.
Jim Hunter
January 25,
I think you can put it inside a DIV and put the height and width for the IFRAME at 100%, then you can size the DIV as normal with JS.
Tony
January 25,
<script language="JavaScript">
<!--
function resize_iframe()
{
//resize the iframe according to the size of the

//window (all these should be on the same line)

document.getElementById("glu").height=
document.body.offsetHeight-
document.getElementById("glu").offsetTop-26;
}

// 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>

And inside your page's body create the iframe tag:

<iframe id='glu' width=100% onload='resize_iframe()'>
</iframe>

Roca
February 24,
Is 100% funciotall all browsers

Hi - Roca
Roca
February 24,
I have set up my Iframe to resize using this code and it works like a charm.

however, MSIE has a bug, it returns an error, yet still works.
the error is refernecing the 'document.getElementById('myframe')' line in, saying "there is no object or is null". i can't have my page return this error, but it works. Any ideas on what to do?


here is my code...

function resize_iframe()
{
//resize the iframe according to the size of the window
var opera = (navigator.userAgent.indexOf("Opera") >= 0)? true: false;
var ie = (document.all && !opera)? true: false;

if (parseInt(navigator.appVersion)>3) {
if (ie) {
document.body.scroll='no'; document.getElementById('myframe').height=document.documentElement.clientHeight-100;
}
else {
document.body.scroll='no';
document.getElementById('myframe').height=window.innerHeight-100;
}
}
}

window.onresize=resize_iframe();

//-->
</script>
Joe Luchette
October 17,
'bump'

I am having the same problem in IE7 and Firefox.
The above script works fine, but the scrolling does not fit into the page.

The script is making the iframe larger then the height of the window.

I you know tot solve i would be very happy.

Thanks in advance
R. vd Houten
February 16,

This topic is archived.

See also:


Back to support forum

Search

Version 2

Looking for AW 2.6 ?
The old site is here.