Results 1 to 2 of 2

Thread: Java script to resize frames

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2001
    Posts
    23

    Java script to resize frames

    Okay, im using the <iframe> tag, and i want to be able to resize this using javaScript from INSIDE the frame. In other words the page in the frame can change the width of the frame whenever needed.
    Does anyone have any clue as to how to do this?
    Thanks in advance,
    Sythe, xxx
    Sythe

  2. #2
    Hyperactive Member
    Join Date
    Aug 2001
    Location
    India
    Posts
    276
    Use this:

    Place this function in the parent HTML File, say try.htm
    Code:
    function adjustFrame (frame) {
      if (document.all) {
        var w = frame.document.body.scrollWidth;
        var h = frame.document.body.scrollHeight;
        document.all[frame.name].width = w;
        document.all[frame.name].height = h;
    }
    <body>
    <iframe name=myframe src=test.htm>
    </iframe>
    </body>
    In the HTML File that is loaded in the IFrame, call this:
    Code:
    Test.htm
    ------------
    <body onload="adjustFrame (this);">
    In the above function, the iFrame is sized to the size of the target document itself...so if u want to hard code the size change the w and h values conveniently.

    - Jemima.

Posting Permissions

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



Click Here to Expand Forum to Full Width