Creating IFRAMEs in Opera

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

    Creating IFRAMEs in Opera

    [Also asked in a private Opera newsgroup.]

    In a javascript-heavy page, an iframe is created to hold information
    from a secondary server CGI process, and the resulting data (in the
    iframe) is used to rewrite some content in the main page. To do this
    transparently, the iframe is created with style="display: none".

    This scheme works great in IE and Mozilla; but Opera apparently doesn't
    load the frame, for some reason. We've seen this behavior using this code
    and the Javascript shell at http://www.squarefree.com/shell/shell.html
    (a great resource):

    1 ifr = document.create Element('iframe ');
    2 ifr.style.displ ay = 'none';
    3 ifr.height = 500;
    4 ifr.width = 500;
    5 ifr.src = 'http://myserver/simpletest.html ';
    6 document.body.a ppendChild(ifr) ;
    7 ifr.style.displ ay = '';

    (While running this script, I have a telnet session open on the server,
    watching Apache's log file: tail -f access_log.)

    Lines 1-4: Create the iframe element and set some attributes.
    Line 5 : Specify the source document.
    This doesn't prompt any server activity. I pause for a
    moment.
    Line 6 : Attach the iframe to the current document. Using Mozilla
    Firefox and Internet Explorer, I see the request on the
    Apache log file. Not so when I use Opera.
    Line 7 : Reset the "display" CSS attribute. When I use Opera, the
    file request happens after this line is executed.

    Playing around a bit, we've noticed that Opera *does* request the file
    immediately after line 6 for style="position : fixed; visibility: hidden",
    rather than "display: none". But this causes the space for the IFRAME to
    be rendered (empty) on the page ... not what we want.

    Compounding this problem is that writing code that detects this condition
    seems difficult, but we don't want to resort to browser sniffing.

    Help?

    Howard Jess
  • Martin Honnen

    #2
    Re: Creating IFRAMEs in Opera



    Howard Jess wrote:

    [color=blue]
    > In a javascript-heavy page, an iframe is created to hold information
    > from a secondary server CGI process, and the resulting data (in the
    > iframe) is used to rewrite some content in the main page. To do this
    > transparently, the iframe is created with style="display: none".[/color]

    It is an optimization not to load the iframe when display is none.
    Mozilla used to do the same, only when web developers complained that
    they wanted to use hidden iframes the way you want to to it (to make
    some hidden request to the server) Mozilla changed the behaviour.

    As a workaround you can use
    <iframe width="0" height="0"
    style="visibili ty: hidden;"
    that way as far as I remember Mozilla, IE, and Opera load the iframe's
    content.

    --

    Martin Honnen


    Comment

    • Howard Jess

      #3
      Re: Creating IFRAMEs in Opera

      Martin Honnen wrote:
      [color=blue]
      > Howard Jess wrote:
      >
      >[color=green]
      >> In a javascript-heavy page, an iframe is created to hold information
      >> from a secondary server CGI process, and the resulting data (in the
      >> iframe) is used to rewrite some content in the main page. To do this
      >> transparently, the iframe is created with style="display: none".[/color]
      >
      > It is an optimization not to load the iframe when display is none.
      > Mozilla used to do the same, only when web developers complained that
      > they wanted to use hidden iframes the way you want to to it (to make
      > some hidden request to the server) Mozilla changed the behaviour.
      >
      > As a workaround you can use
      > <iframe width="0" height="0"
      > style="visibili ty: hidden;"
      > that way as far as I remember Mozilla, IE, and Opera load the iframe's
      > content.[/color]

      Why the operational difference between a 0-pixel invisible frame and a
      non-displayed frame? Also, your workaround uses HTML: Opera's behavior
      in that case (static HTML on the page) is the same as Mozilla's and IE's:
      the frame data is loaded along with other external data for the page. (That
      is, pretty much immediately, along with <img src=...> and <script src=...>
      data.) It's only when you create the iframe dynamically and append it to
      a document element that this behavior (non-loading if display:none) occurs.

      My original post was a contrived example. We're trying to build support
      routines for general use (in which case we have no say over what the
      programmer/designer may write), while preserving identical behavior across
      various browsers. Although your workaround suffices (adding "position: fixed"
      to the iframe style), it doesn't help in the general case. And begs the
      question above: why does Opera not load a non-displayed document, but it
      *does* load an invisible one? And, why does it behave differently for
      dynamically- and statically-created iframes?


      hj

      Comment

      • Martin Honnen

        #4
        Re: Creating IFRAMEs in Opera



        Howard Jess wrote:

        [color=blue]
        > My original post was a contrived example. We're trying to build support
        > routines for general use (in which case we have no say over what the
        > programmer/designer may write), while preserving identical behavior across
        > various browsers. Although your workaround suffices (adding "position: fixed"
        > to the iframe style), it doesn't help in the general case. And begs the
        > question above: why does Opera not load a non-displayed document, but it
        > *does* load an invisible one? And, why does it behave differently for
        > dynamically- and statically-created iframes?[/color]

        I am not qualified to explain Opera behaviour (well unless there is a
        standard Opera is following and IE not for instance but I don't think
        the CSS standard is going into detail as to wheter to load an element
        with display: none), you will need to ask someone at Opera and I think
        you have done that in an Opera newsgroup. It was also suggested there
        that you file a bug if you think you have experienced one.

        If the workarounds suggested here and in the Opera newsgroup don't help
        with your general case you will need to provide more information to
        enable anyone to try to help you get the same behaviour with Opera as
        with Mozilla or IE.

        --

        Martin Honnen


        Comment

        • Howard Jess

          #5
          Re: Creating IFRAMEs in Opera

          Martin Honnen wrote:
          [color=blue]
          > Howard Jess wrote:
          >[color=green]
          >> My original post was a contrived example. We're trying to build support
          >> routines for general use (in which case we have no say over what the
          >> programmer/designer may write), while preserving identical behavior across
          >> various browsers. Although your workaround suffices (adding "position: fixed"
          >> to the iframe style), it doesn't help in the general case. And begs the
          >> question above: why does Opera not load a non-displayed document, but it
          >> *does* load an invisible one? And, why does it behave differently for
          >> dynamically- and statically-created iframes?[/color]
          >
          > I am not qualified to explain Opera behaviour (well unless there is a
          > standard Opera is following and IE not for instance but I don't think
          > the CSS standard is going into detail as to wheter to load an element
          > with display: none), you will need to ask someone at Opera and I think
          > you have done that in an Opera newsgroup. It was also suggested there
          > that you file a bug if you think you have experienced one.[/color]

          Thanks; as you suggested, I've submitted a bug to Opera. I asked the
          question here and on the Opera newsgroup hoping that someone else had
          already encountered this behavior and could explain it, and/or suggest
          some other (Opera-proprietary, if necessary) way to make it work as it
          seems it should.

          Regards,

          hj

          Comment

          Working...