473,700 Members | 2,538 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems getting same-domain IFRAME content in FireFox

Hi folks

I've googled for an answer to this, with no success. Can someone please
jump in, and put me out of my misery! (I'm sure it's quite simple)

I have an invisible IFRAME, and a visible DIV:

<IFRAME id=myframe style="display: none" src="..."
onload="ShowNew s(this)"></IFRAME>

<DIV id=mydiv></DIV>

I need to copy the content from the IFRAME, into the DIV. Everything
comes from the same domain, so there are definitely not any
cross-domain security issues.

This works fine in IE6:

function ShowNews(x) {
document.all.my div.innerHTML =
x.contentWindow .document.body. outerHTML
}

but in Firefox 1.5 it fails with the error,
"x.contentWindo w.document.body has no properties".

I've tried various changes, with no success.

How can I recode that statement, so it works in either browser?

TIA,
TC (MVP MSAccess)
http://tc2.atspace.com

Mar 20 '06 #1
9 11175
TC
PS. The source of the IFRAME is an RSS XML file. The XML file specifies
an XLS stylesheet. The XSL stylesheet transforms the XML into HTML. At
present, the HTML (produced by that transformation) starts with <BODY>,
and ends with </BODY>.

TC

Mar 20 '06 #2
aa**********@ya hoo.com wrote:
Hi folks

I've googled for an answer to this, with no success. Can someone please
jump in, and put me out of my misery! (I'm sure it's quite simple)

I have an invisible IFRAME, and a visible DIV:

<IFRAME id=myframe style="display: none" src="..."
onload="ShowNew s(this)"></IFRAME>

<DIV id=mydiv></DIV>

I need to copy the content from the IFRAME, into the DIV. Everything
comes from the same domain, so there are definitely not any
cross-domain security issues.

This works fine in IE6:

function ShowNews(x) {
document.all.my div.innerHTML =
x.contentWindow .document.body. outerHTML
}

but in Firefox 1.5 it fails with the error,
"x.contentWindo w.document.body has no properties".

I've tried various changes, with no success.

How can I recode that statement, so it works in either browser?

TIA,
TC (MVP MSAccess)
http://tc2.atspace.com


I don't know if this helps, but I've done something like this:

I've put a div tag inside the IFrame document and a small javascript
snippet at the end that takes the innerHTML from the div and sends it
to the parent window.

"index.html ":
<html>
<head>
<script language="javas cript" type="text/javascript">
<!--
var global_variable _1 = "<p>No page found</p>";
function make_global(var iable_a)
{
global_variable _1 = variable_a;
}
function present_site()
{
document.getEle mentById("where _to_put_loaded_ page").innerHTM L =
global_variable _1;
}
//-->
</script>
</head>
<body onload="present _site()">
[...]
<div id="where_to_pu t_loaded_page">
Initial text here is: no page loaded.
</div>
<iframe style="visibili ty: hidden" src="page1.html "></iframe>
</body>
</html>

"page1.html " (loaded page):
<html>
<body>
[...]
<div id="meaningful_ content">
Here I put the content that I want dynamically loaded in the main page.
</div>
[...]
<script language="javas cript" type="text/javascript">
<!--

this.parent.mak e_global(docume nt.getElementBy Id("meaningful_ content").inner HTML);

//-->
</script>
</body>
</html>

So basically I send the content from the IFrame to the main page via a
global variable and take/replace it via innerHTML. The only problem
with this is
that the iframe css doesn't get "shipped" to the main page. I've
temporarily solved that
by inlining the css, but if you find a better way, please tell me.

Mar 20 '06 #3
TC
Thanks for the suggestion. But in my case, the IFRAME content can't be
modified in the way you propose.

/Surely/ there's some way to get the content of an IFRAME, that will
work in Firefox?

This is the first time I've used Firefox, instead of IE. But at
present, IE works & Firefox doesn't. Grrrrrr #^%$%#$ :-(((

TC (MVP MSAccess)
http://tc2.atspace.com

Mar 20 '06 #4

aa**********@ya hoo.com wrote:
Hi folks

I've googled for an answer to this, with no success. Can someone please
jump in, and put me out of my misery! (I'm sure it's quite simple)

I have an invisible IFRAME, and a visible DIV:

<IFRAME id=myframe style="display: none" src="..."
onload="ShowNew s(this)"></IFRAME>

<DIV id=mydiv></DIV>

I need to copy the content from the IFRAME, into the DIV. Everything
comes from the same domain, so there are definitely not any
cross-domain security issues.

This works fine in IE6:

function ShowNews(x) {
document.all.my div.innerHTML =
x.contentWindow .document.body. outerHTML
}

but in Firefox 1.5 it fails with the error,
"x.contentWindo w.document.body has no properties".

I've tried various changes, with no success.


You could try Googling: contentWindow +mozilla

To reference a div's content use:
document.getEle mentById('mydiv ').innerHTML

You can reference the content of the document in an iframe via its
/name/, using:

window.frames[x].document.body. innerHTML

Mozilla doesn't appear to support outerHTML

It seems that contentWindow is available only as a property of the
value returned by document.getEle mentById, so to reference the iframe
by ID, try:

document.getEle mentById('mydiv ').innerHTML =
document.getEle mentById(x).con tentWindow.docu ment.body.inner HTML;

or to amend your onload statement:

onload="ShowNew s(this.id)"

--
S.C.

Mar 20 '06 #5
aa**********@ya hoo.com wrote:
<IFRAME id=myframe style="display: none" src="..."
onload="ShowNew s(this)"></IFRAME>

<DIV id=mydiv></DIV>

I need to copy the content from the IFRAME, into the DIV. Everything
comes from the same domain, so there are definitely not any
cross-domain security issues.

This works fine in IE6:

function ShowNews(x) {
document.all.my div.innerHTML =
x.contentWindow .document.body. outerHTML
}


Welcome to the wonderful world of two ways to do the same thing.
Now in your case, there are three differences!
FF does not have .all, .contentWindow, nor .outerHTML
but a div shouldn't be getting a <body> element, so perhaps try:

function ShowNews(x) {
document.getEle mentById('mydiv ').innerHTML =
(x.contentDocum ent || x.contentWindow .document).body .innerHTML; }

where x is the IFRAME element (document.getEl ementById('myFr ame');

Csaba Gabor from Vienna

Mar 20 '06 #6
TC
Thanks Stephen, I will try your suggestions & post back here in due
course.

TC (MVP MSAccess)
http://tc2.atspace.com

Mar 21 '06 #7
TC
Thanks Csaba, I will try your suggestions & post back here in due
course.

TC (MVP MSAccess)
http://tc2.atspace.com

Mar 21 '06 #8
TC
Geez, how hard could this friggin' be? !!

This is how I eventually managed to copy the content of an invisible
IFRAME, into a visible DIV, so it works in IE6 *and* FireFox 1.5.

Everything comes from the same domain, so there are no security issues.
This is the only solution that worked for me. All the others got
various errors in one or both browsers.
the DIV:

<DIV ID=mydiv>
</DIV>

the IFRAME:

<IFRAME ID=myframe SRC=... STYLE="display: none">
</IFRAME>

the code:

var x = document.getEle mentById('myfra me');
document.getEle mentById('mydiv ').innerHTML =
(x.contentDocum ent ||
x.contentWindow .document).docu mentElement.inn erHTML;
Thanks to all who tried to help. I hope that this helps someone else!

TC (MVP MSAccess)
http://tc2.atspace.com

Mar 24 '06 #9
Cheers TC, that helped me!

I've googled around for this solution and read too many responses from
people 'guessing' that document.getEle mentById("myIfr ame").innerHTM L
would work.

*** Sent via Developersdex http://www.developersdex.com ***
Jun 6 '06 #10

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

Similar topics

9
2046
by: leke | last post by:
Hi, I am trying to learn PHP but am having some problems getting my code running in Explorer 6. <html> <head> <title>PHP Test</title> </head> <body> <?php echo '<p>Hello World</p>'; ?> </body>
4
2802
by: Mxsmanic | last post by:
The require() I'm using in a PHP script has stopped working after I moved from PHP4 and Apache 1.3.x to PHP5 and Apache 2.x. Now I get messages like this: Warning: main(/includes/ReloadScript.html) : failed to open stream: No such file or directory in /usr/local/www/htdocs/main/AOLCompression.php on line 14 Fatal error: main() : Failed opening required '/includes/ReloadScript.html' (include_path='.:/usr/local/lib/php') in
2
4254
by: Michael Hatmaker | last post by:
I have begun experimenting with web services, and I created some simple web services in C# and was able to install them with IIS and create an equally simple C# client to consume them. My next experiment was to use Python to consume these same web services, and even though I am able to get Python to consume web services from a variety of sources (Apache SOAP, Glue, AXIS), I cannot get web services created with MS.NET to work. Actually,...
6
1703
by: Affan Syed | last post by:
Hi, I am getting this weird problem. I know what i am doing is strange.. i am using C++ vectors and fopen, but for some reason if i used ofstream in the similar scenario it would give me errors. So here is what i do. I create a new node and insert it in a vecotr as follows: nodeCreator = new cNode(location, skew, offset,Beaconify,nodeId,directory); gNodeVector.push_back(*nodeCreator); //now lets delete the memory we created for the node
36
3198
by: Chuck Faranda | last post by:
I'm trying to debug my first C program (firmware for PIC MCU). The problem is getting serial data back from my device. My get commands have to be sent twice for the PIC to respond properly with the needed data. Any ideas? Here's the code in question, see any reason why a command would not trigger the 'kbhit' the first time a serial command is sent?: Thanks! Chuck **************************************************** while(1) //...
4
2100
by: chris | last post by:
Hello all, I am having problems getting Apache 2.2.4 to read the php_mysqli.dll file some my C:\php\ext\ directory. The following is the error that Apache displays in the error log: PHP Warning: PHP Startup: Unable to load dynamic library 'C:/php/ext/ php_mysqli.dll' - The specified procedure could not be found.\r\n in Unknown on line 0 The file is in the directory, but Apache won't load the file.
2
3573
by: rustyc | last post by:
Well, here's my first post in this forum (other than saying 'HI' over in the hi forum ;-) As I said over there: ... for a little side project at home, I'm writing a ham radio web site in uby/Rails. I started it in Perl and gave up on Perl as I went from the 'display the database information on the web page' to the 're-display the information from the database and allow the user to update the database using the web page' stage and realized...
0
953
by: Yansky | last post by:
Hi, I'm having a lot of problems getting any Python scripts to run on my website. I have put them in the cgi-bin directory and chmodded both the directory and files to 755. But when I try to access the script, I get a 404 error: http://forboden.com/cgi-bin/wp.py I also tried running them from another directory and giving the directory its own .htaccess file containing: Options +ExecCGI AddHandler cgi-script .py
5
1571
by: bodhiSoma | last post by:
Hi all. Can't seem to get PHP to play nice with MySQL. First I logged into MySQL, created the db, switched to it and then granted (what I thought were) correct privileges: -------- Macintosh-7:~ jason$ /usr/local/mysql/bin/mysql -u root mysqlcreate database wes;
4
1799
by: lafayettejohnson | last post by:
there are 3 files but the one iam having problems with is the student.cpp student.cpp #include <iostream> // for ostream << and istream >> #include <string> #include "student.h" using namespace std;
0
8726
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8645
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9075
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8925
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7810
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5903
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.