HELP: Dynamically resizing iFrame

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sticky

    HELP: Dynamically resizing iFrame

    I really need some help - i have already pulled out 1/2 my hear and
    the rest is following quickly.....

    I am designing a page containing an iFrame, the contents of which are
    selected dynamically by the user, and it needs to resize
    correspondingly - both height and width. the width isn't a problem; it
    is set from its parent object using width=100%, but the height is a
    killer.

    Basically the user selects a menu item and the src of the iFrame is
    set to that choice, but each selection has a different height - and
    the width of the iframe also changes depending on the width of the
    menu to its left.

    i have tried to set a dynamic expression in its style property:

    style="height:e xpression(docum ent.contentIFra me.window.conte ntTable.clientH eight)"

    but this works erratically

    i have tried writing a seperate function which resizes the iframe when
    a new choice is made, but have found that the function sets the iframe
    to the height of the PREVIOUS object displayed. i cannot seem to be
    able to access the current object no matter how i do it?

    function setSize() {

    //contentIFrame.w indow.document. recalc(true);

    contentIFrame.f rames.frameElem ent.style.heigh t =
    contentIFrame.w indow.contentTa ble.clientHeigh t;

    }


    Any ideas

    cheers

    tim
  • Trent

    #2
    Re: HELP: Dynamically resizing iFrame

    Is JavaScript an option? Try:

    h = document.body.s crollHeight;
    w = document.body.s crollWidth;
    this.style.heig ht = h + 20;
    this.style.widt h = w + 20;

    This might be slightly off, but I've done something similar to that in the past.

    Comment

    • Sticky

      #3
      Re: HELP: Dynamically resizing iFrame

      spacerook@marx7 .org (Trent) wrote in message news:<221fd1f2. 0312151233.bbd1 754@posting.goo gle.com>...[color=blue]
      > Is JavaScript an option? Try:
      >
      > h = document.body.s crollHeight;
      > w = document.body.s crollWidth;
      > this.style.heig ht = h + 20;
      > this.style.widt h = w + 20;
      >
      > This might be slightly off, but I've done something similar to that in the past.[/color]

      Mate your a ledgend!!
      thought id send a reply to let you know how i solved the problem - the
      scrollHeight didnt work directly (although it did access the correct
      height), as the iFrame was still somehow caching the values of the
      previous content element, or not updating them quickly enough.

      BUT by calling a function to set the size of the iFrame after the
      contents have been updated:

      function setSize() {

      contentIFrame.f rames.frameElem ent.style.heigh t =
      contentIFrame.d ocument.body.sc rollHeight;

      }

      and then calling the function again in the onload event of the iFrame
      the cached values (or how ever the problem is caused) are updated in
      time for the second call.

      Thanks

      Comment

      Working...