473,243 Members | 1,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,243 software developers and data experts.

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.createElement('iframe');
2 ifr.style.display = 'none';
3 ifr.height = 500;
4 ifr.width = 500;
5 ifr.src = 'http://myserver/simpletest.html';
6 document.body.appendChild(ifr);
7 ifr.style.display = '';

(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
Jul 23 '05 #1
4 1988


Howard Jess wrote:

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".


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="visibility: hidden;"
that way as far as I remember Mozilla, IE, and Opera load the iframe's
content.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
Martin Honnen wrote:
Howard Jess wrote:

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".


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="visibility: hidden;"
that way as far as I remember Mozilla, IE, and Opera load the iframe's
content.


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

Jul 23 '05 #3


Howard Jess wrote:

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?


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
http://JavaScript.FAQTs.com/

Jul 23 '05 #4
Martin Honnen wrote:
Howard Jess wrote:
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?


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.


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

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Dan Popa | last post by:
Check out the following 2 links: http://www.batisdev.com/admin/test_1images.asp http://www.batisdev.com/admin/test_2images.asp First page contain 4 IFRAMES and 1 IMG tags. Second page contain 4...
8
by: Steinar Bang | last post by:
Is there a way to catch HTTP 4xx and 5xx errors occuring in an IFRAME? I want to replace the blue and white tomcat error pages, with a small discrete text saying "The page currently not available"....
7
by: bscofield | last post by:
What would be the danger in having a lot of hidden iframes? i.e. potentialy 30-40. I need to store a bunch of data and thought about using hidden iframes to do it but wasn't sure if this would bog...
1
by: innov8iv | last post by:
One page, several iFrames. Each contains its own mini web page. Is it not possible to "go back" to a previous page within a particular iFrame? (While leaving the others in their current state.) ...
6
by: adnanx82 | last post by:
Hi, I was wondering if anyone knew how to perform the following 2 tasks in Javascript: 1) distinguish between frames and iframes (during an onload event for example) 2) figure out whether a...
16
by: Mcginkel | last post by:
I am trying to find a way to load XHTML content in an Iframe. I use to do this in html by using the following code : var iframeObject = document.createElement("iframe");...
8
by: Kenny Lai | last post by:
hey, Is there a way to communicate between iframes on different subdomains? e.g. from one.dot.com to two.dot.com? there is a security access restriction passing javascript commands between...
5
by: luckydenis2007 | last post by:
I am trying to access image information that is displayed using iframe. iframe code looks like this: <iframe id="testImage" src="/images/someimg.gif" scrolling="yes" frameborder="0"...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.