...

View Full Version : Cannot set height property with variable



davide@wireless
10-31-2008, 07:18 AM
Hi,

I read the height querystring value from a url in an .aspx page via javascript.

I use the following javascript to read the height value:


<script type="text/javascript" language="javascript">

var params = window.location.search.substring(1).split( '&' );
var iheight;

for( var i = 0, l = params.length; i < l; ++i )
{
var parts = params[i].split( '=' );
switch( parts[0] )
{
case 'height':
iheight = parseInt( parts[1] );
alert(iheight);
break;
}
}
//iheight = 2000;
document.getElementById('searchIFrame').setAttribute('height',iheight);

</script>

I have an iframe on the same page and I want to set the height of the frame to the height of the iheight variable

<iframe src="link to page" id="searchIFrame" width="600" height="400" scrolling="auto" frameborder="1"></iframe>

The problem that I have is that as soon as I hard code the iheight = 2000; variable then the frame grows, but when I use the variable from the querystring then I cannot set the height property. In other words:

document.getElementById('searchIFrame').setAttribute('height',iheight);
Is NOT working

, but

document.getElementById('searchIFrame').setAttribute('height',2000);
Is working

All I am trying to achieve is to set the height property of an inline frame when the form loads using a variable that I set getting the value from a querystring.

Is there maybe there is another way to do this?

Please help?

Thanks

abduraooft
10-31-2008, 07:50 AM
How about

document.getElementById('searchIFrame').style.height=iheight+'px';



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum