473,473 Members | 1,947 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 1994


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"...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.