problem with iframe resizing 2

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

    problem with iframe resizing 2

    Can someone help me here because this is really killing me!

    the problem is, i have this javascript code in my aspx page that i want it
    to work on almost all browsers, especially opera and safari :

    function resize(){
    displayFrm = document.getEle mentById("ifrmD isplay");

    innerDoc = (displayFrame.c ontentDocument) ?displayFrm.con tentDocument :
    displayFrm.cont entWindow.docum ent;

    objToResize = (displayFrm.sty le) ? displayFrm.styl e : displayFrm;

    objToResize.hei ght = innerDoc.body.s crollHeight;
    }

    the code above gets called every time a new page is loaded inside the iframe
    (ifrmDisplay) what its doing is resizing the iframe so it can have the same
    size as the page inside it, so i can eliminate the need for vertical
    scroller for the iframe, i assumed that it works on opera and IE at the same
    time, when i tried it out, it worked on IE but not on opera. after lot of
    time in researching how i can get workaround this issue with opera, that is
    the best possible solution i have and yet it doesnt work. so i gave up and
    asking you if you can help me out here , coz this is jst driving me crazy!

    the problem is im not a javascript expert, to be honest i jst started doing
    javascripts about two days ago, that is why im in need for help

    by the way, here is inner html for the iframe if its any use

    <iframe id="ifrmDisplay " style="Z-INDEX: 99; LEFT: 187px; WIDTH: 567px;
    POSITION: absolute; TOP: 136px; HEIGHT: 408px" src="" scrolling="no"
    onload="resize( );">
    </iframe>


  • Julian Turner

    #2
    Re: problem with iframe resizing 2

    Hello

    Some quick thoughts.

    You may need to be clearer about what exactly is not working.

    Is it that:-

    (1) the IFRAME onload event (and resize function) is not firing at
    all, or

    (2) that the resize function is not working as expected (i.e. the
    height is not the desired height)?

    1. ONLOAD EVENT

    I think (I could be wrong) that Opera does not support the onload
    event on the IFRAME element.

    It does however I think support the "readyState " property on
    documents.

    So in Opera, your only way may be to include either:-

    (a) Some script within the web page to be loaded in the IFRAME, that
    calls the parent method:-

    <BODY onload="window. parent.resize(' IFRAMEID')">

    (b) Monitor the document readyState from the parent using a
    setInterval process.

    I.e. if (myIFrame.conte ntWindow.docume nt.readyState== "complete"){res ize();}

    2. IFRAME not resizing properly

    The scrollHeight value may not be reliable.

    Browsers may vary as to whether they take into account margins around
    HTML and BODY elements. So you may need to experiment a little here.

    Also, you need to take into account the borders and margins of the
    IFRAME element itself.

    3. FURTHER READING

    A useful page on IFRAMES is:-



    A similar post on another site:-



    Julian

    Comment

    Working...