Results 1 to 3 of 3

Thread: Resize Iframe Script and Opera

  1. #1
    Join Date
    Nov 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Resize Iframe Script and Opera

    1) Script Title: Resize Iframe Script © John Davenport Scheuer

    2) Script URL (on DD): http://www.dynamicdrive.com/forums/s...ead.php?t=9139

    3) Describe problem: Hi, I am experiencing some issues with this script when I try it on Opera, on IE all works fine.

    Note: You must use Opera for the problems to appear.

    Here is what is happening:
    - If the page does not need a scrollbar, all goes fine.
    - If the page needs a scrollbar it will appear but all the other pages will have that same scrollbar.
    - If the page needs a longer scrollbar it will work fine, whatever page was loaded first, it will resize a smaller scrollbar just fine.
    - If the page needs a shorter scrollbar and I loaded a page with a larger one, it will not resize unless I refresh the page.

    Thanks for the help! and I can provide the source of those pages without a problem, simply ask.
    Last edited by Samus Aran; 11-26-2007 at 06:19 AM.

  2. #2
    Join Date
    Nov 2007
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The source of the rzPIframe.js file is:

    /* Resize Iframe Script © John Davenport Scheuer
    As first seen in http://www.dynamicdrive.com/forums
    User Name: jscheuer1
    This Credit Must Remain for Legal Use
    */

    function resizeParentIframe(){
    var pad=window.opera? 0 : document.all? 4 : 20;
    function iecompattest(){
    return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
    }
    function collectWidth(){
    var wVal=0
    var objs=document.getElementsByTagName('*')
    for (var i_tem = 0; i_tem < objs.length; i_tem++){
    wVal=Math.max(objs[i_tem].offsetWidth, wVal)
    }
    return wVal;
    }
    parent.document.getElementsByName(window.name)[0].style.height=''
    var resizeHeight=document.all? iecompattest().scrollHeight : iecompattest().offsetHeight;
    var resizeWidth=window.opera? collectWidth() : iecompattest().scrollWidth;
    resizeHeight+=parent.document.getElementsByName(window.name)[0].offsetWidth<resizeWidth? 18 : 0;
    parent.document.getElementsByName(window.name)[0].style.height=resizeHeight + pad + 'px'
    }

    if ( document.getElementsByName && window.name && location.href!==top.location.href && parent.document.getElementsByName(window.name)[0].tagName.toLowerCase()=='iframe' ) {
    if ( typeof window.addEventListener != "undefined" ) {
    window.addEventListener( "load", resizeParentIframe, false );
    parent.window.addEventListener( "resize", resizeParentIframe, false );
    }
    else if ( typeof window.attachEvent != "undefined" ) {
    window.attachEvent( "onload", resizeParentIframe );
    parent.window.attachEvent( "onresize", resizeParentIframe );
    }
    else {
    if ( window.onload != null ) {
    var oldOnload = window.onload;
    window.onload = function ( e ) {
    oldOnload( e );
    resizeParentIframe();
    };
    }
    else
    window.onload = resizeParentIframe;

    if ( parent.window.onresize != null ) {
    var oldOnresize = parent.window.onresize;
    parent.window.onresize = function ( e ) {
    oldOnresize( e );
    resizeParentIframe();
    };
    }
    else
    parent.window.onresize = resizeParentIframe;
    }
    }

  3. #3
    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

    As far as I'm concerned, and I wrote the mod you are referring to, this entire concept is flawed. The iframe tag has already been deprecated. Any implementation of iframe suffers therefore from a lack of standards. This doesn't mean that iframe cannot be used for anything, just that it is tricky, and unlikely to be very 'future proof'. From experience, I can tell you that resizing an iframe in any browser is even trickier, dependant upon the markup and style of both the top and external pages. My demo page of the mod works, or worked in Opera when I made it. Other than that, you folks are on your own, sorry.

    For many but not all things that one would want to use resizable iframe for, Ajax importation to a division is a better choice.

    Scripting between iframes' top and contained pages (as in resizing to content), and importing content via Ajax both require that both pages are on the same domain.
    Last edited by jscheuer1; 11-26-2007 at 08:06 AM. Reason: add info
    - John
    ________________________

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

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
  •