Results 1 to 3 of 3

Thread: Size of an Iframe according to DIV..

  1. #1
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Size of an Iframe according to DIV..

    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

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Your iframe would need an id (in my code I use iframe_id as a stand in) and this is what you would do:

    Code:
    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".
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •