Log in

View Full Version : Size of an Iframe according to DIV..



tricker
07-31-2007, 07:57 AM
Hello All,

In my recent project i need to similarise the height and width of an iframe according to div size using javascript.

bcoz page is dynamic so height and width of the div is not fixed..

code:
<iframe border="0"></iframe>
<div id="abc">
<table width="100%" border="1">
<tr>
<th>one</th>
<th>two</th>
<th>three</th>
<th>four</th>
<th>five</th>
<th>six</th>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
<td>4</td>
<td>5</td>
<td>6</td>
</tr>
</table>
</div>

any help or pointer for the same is highly appriciable..

Thanks,
Tricker

jscheuer1
07-31-2007, 03:50 PM
Your iframe would need an id (in my code I use iframe_id as a stand in) and this is what you would do:


document.getElementById('iframe_id').width=document.getElementById('abc').offsetWidth;
document.getElementById('iframe_id').height=document.getElementById('abc').offsetHeight;

But I can't tell (from what you have shown us) when or where you should do it other than to say, "after each time the division changes its size".

tricker
08-01-2007, 04:37 AM
Hi jscheuer1,

Thanks for the prompt reply!!

Reason:
======

Layer popsup on a click of a link in the page and page also contains some form elements like drop down and text box etc..

now problem is when div pops up drop down is always overalps the popup divs. Solutions for the same is iframe. We can hide the drop down by using iframe between the page and the popup div..

because height and width of the popup div depends upon the table inside the popup div and all the data comes into the table is dynamic..

anyways thanks once again

Regards,
Tricker Baron