473,396 Members | 1,975 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,396 software developers and data experts.

IFrame.onload, IE and Remote Scripting

IFrames have been used by years for people to accomplish many of the
tasks the XMLHttpRequest does for them now...I unfortunately am late
in the game and XMLHttpRequest was already out there by the time I got
serious about using Javascript for more than just rollover images...

I now would like to learn about the concept for the purposes of
creating Ajax-like requests across domains.

I felt like I had the basic concept down, but am running into a few
issues I'd like the experts to help me with...

First I am trying to perform all this as a .js file without any
requirements from the end-user (i.e. they don't have to create an
iframe in their document OR they won't have to specify an onload
handler in their server response)...and there I am creating the iframe
programmatically using this:

iframe = document.createElement('IFRAME');
iframe.width = 0;
iframe.height = 0;
iframe.style.border = 'none';
iframe.id = "internal_frame";
iframe.name = "internal_frame";
iframe.src= "blank.html";
iframe.onload = function() { alert('Something'); };
document.body.appendChild(iframe);

I then load cross-domain requests by setting the src attribute of the
iframe. In opera and FF, I get my little alert box, so I'm good to go
and read the iframe's contents... But in IE, I do not get an alert
box. Therefore I don't know how to be alerted when the load is
complete so the rest of my code can go and read the contents.

Second of all...what is the best way to obtain the contents of the
iframe (the server response) from the onload event handling function?

I'm sorry if this is so old school, it's just very new to me.

Mar 23 '07 #1
7 9598
ASM
Tom Cole a écrit :
>
and there I am creating the iframe
programmatically using this:

iframe = document.createElement('IFRAME');
iframe.width = 0;
iframe.height = 0;
iframe.style.border = 'none';
iframe.id = "internal_frame";
iframe.name = "internal_frame";
iframe.src= "blank.html";
iframe.onload = function() { alert('Something'); };
document.body.appendChild(iframe);

I then load cross-domain requests by setting the src attribute of the
iframe. In opera and FF, I get my little alert box, so I'm good to go
and read the iframe's contents... But in IE, I do not get an alert
box.
With IE do you get the new file in your iframe ?

Probably better result with :
parent.internal_iframe.location = 'my_new_file.htm';
than using setAttribute();
Second of all...what is the best way to obtain the contents of the
iframe (the server response) from the onload event handling function?
I'am not very sure you'll be authorized to get the content of the iframe ...
especially if this content comes from another domain.
nota :
You can also use an 'object' insteed of an 'iframe' to include some html
file.
(with much more restrictions about cross domain)
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 23 '07 #2
On Mar 23, 6:10 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
Tom Cole a écrit :


and there I am creating the iframe
programmatically using this:
iframe = document.createElement('IFRAME');
iframe.width = 0;
iframe.height = 0;
iframe.style.border = 'none';
iframe.id = "internal_frame";
iframe.name = "internal_frame";
iframe.src= "blank.html";
iframe.onload = function() { alert('Something'); };
document.body.appendChild(iframe);
I then load cross-domain requests by setting the src attribute of the
iframe. In opera and FF, I get my little alert box, so I'm good to go
and read the iframe's contents... But in IE, I do not get an alert
box.

With IE do you get the new file in your iframe ?

Probably better result with :
parent.internal_iframe.location = 'my_new_file.htm';
than using setAttribute();
I have no problem loading the page(s), the only issue is that the
function declared in this line:

iframe.onload = function() { alert('Something'); };

never gets executed in IE, although it executes perfectly after
loading in Opera and in Firefox.
>
Second of all...what is the best way to obtain the contents of the
iframe (the server response) from the onload event handling function?

I'am not very sure you'll be authorized to get the content of the iframe ....
especially if this content comes from another domain.
That's what I'm experiencing, I'm getting security exceptions in Opera
and in Firefox. So how can RPC to another domain be done?

My situation is that I have one business that is hosting several
websites with products for specific industries. But at the end of the
day all the orders are processed the same and arrive in the same
system. I can reuse the same base of servlets to accept and process
all the orders without having to concern myself with making sure X
websites all have the latest version of a servlet.
>
nota :
You can also use an 'object' insteed of an 'iframe' to include some html
file.
(with much more restrictions about cross domain)
Thanks.
>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date- Hide quoted text -

- Show quoted text -

Mar 23 '07 #3
>So how can RPC to another domain be done?

On the server.

(sorry for the 'top' post)

"Tom Cole" <tc****@gmail.comwrote in message
news:11*********************@b75g2000hsg.googlegro ups.com...
On Mar 23, 6:10 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
Tom Cole a écrit :
and there I am creating the iframe
programmatically using this:
iframe = document.createElement('IFRAME');
iframe.width = 0;
iframe.height = 0;
iframe.style.border = 'none';
iframe.id = "internal_frame";
iframe.name = "internal_frame";
iframe.src= "blank.html";
iframe.onload = function() { alert('Something'); };
document.body.appendChild(iframe);
I then load cross-domain requests by setting the src attribute of the
iframe. In opera and FF, I get my little alert box, so I'm good to go
and read the iframe's contents... But in IE, I do not get an alert
box.

With IE do you get the new file in your iframe ?

Probably better result with :
parent.internal_iframe.location = 'my_new_file.htm';
than using setAttribute();
I have no problem loading the page(s), the only issue is that the
function declared in this line:

iframe.onload = function() { alert('Something'); };

never gets executed in IE, although it executes perfectly after
loading in Opera and in Firefox.
>
Second of all...what is the best way to obtain the contents of the
iframe (the server response) from the onload event handling function?

I'am not very sure you'll be authorized to get the content of the iframe
...
especially if this content comes from another domain.
That's what I'm experiencing, I'm getting security exceptions in Opera
and in Firefox. So how can RPC to another domain be done?

My situation is that I have one business that is hosting several
websites with products for specific industries. But at the end of the
day all the orders are processed the same and arrive in the same
system. I can reuse the same base of servlets to accept and process
all the orders without having to concern myself with making sure X
websites all have the latest version of a servlet.
>
nota :
You can also use an 'object' insteed of an 'iframe' to include some html
file.
(with much more restrictions about cross domain)
Thanks.

<snip>
Mar 23 '07 #4
On Mar 23, 6:40 pm, "Marc" <sorry...@dirtymail.comwrote:
So how can RPC to another domain be done?

On the server.
Fair enough.
>
(sorry for the 'top' post)

"Tom Cole" <tco...@gmail.comwrote in message

news:11*********************@b75g2000hsg.googlegro ups.com...
On Mar 23, 6:10 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:


Tom Cole a écrit :
and there I am creating the iframe
programmatically using this:
iframe = document.createElement('IFRAME');
iframe.width = 0;
iframe.height = 0;
iframe.style.border = 'none';
iframe.id = "internal_frame";
iframe.name = "internal_frame";
iframe.src= "blank.html";
iframe.onload = function() { alert('Something'); };
document.body.appendChild(iframe);
I then load cross-domain requests by setting the src attribute of the
iframe. In opera and FF, I get my little alert box, so I'm good to go
and read the iframe's contents... But in IE, I do not get an alert
box.
With IE do you get the new file in your iframe ?
Probably better result with :
parent.internal_iframe.location = 'my_new_file.htm';
than using setAttribute();

I have no problem loading the page(s), the only issue is that the
function declared in this line:

iframe.onload = function() { alert('Something'); };

never gets executed in IE, although it executes perfectly after
loading in Opera and in Firefox.
Second of all...what is the best way to obtain the contents of the
iframe (the server response) from the onload event handling function?
I'am not very sure you'll be authorized to get the content of the iframe
...
especially if this content comes from another domain.

That's what I'm experiencing, I'm getting security exceptions in Opera
and in Firefox. So how can RPC to another domain be done?

My situation is that I have one business that is hosting several
websites with products for specific industries. But at the end of the
day all the orders are processed the same and arrive in the same
system. I can reuse the same base of servlets to accept and process
all the orders without having to concern myself with making sure X
websites all have the latest version of a servlet.
nota :
You can also use an 'object' insteed of an 'iframe' to include some html
file.
(with much more restrictions about cross domain)

Thanks.

<snip>- Hide quoted text -

- Show quoted text -

Mar 23 '07 #5
ASM
Tom Cole a écrit :
On Mar 23, 6:10 pm, ASM <stephanemoriaux.NoAd...@wanadoo.fr.invalid>
wrote:
>With IE do you get the new file in your iframe ?

Probably better result with :
parent.internal_iframe.location = 'my_new_file.htm';
than using setAttribute();

I have no problem loading the page(s), the only issue is that the
function declared in this line:

iframe.onload = function() { alert('Something'); };
and ... did you try the foo.location.href way ?

(setting attribute is it really same as downloading ?)
never gets executed in IE,
most of the time old JS is better digested by IE
although it executes perfectly after
loading in Opera and in Firefox.
he oui ! they are serious browsers. :-)
>I'am not very sure you'll be authorized to get the content of the iframe ...
especially if this content comes from another domain.

That's what I'm experiencing, I'm getting security exceptions in Opera
and in Firefox. So how can RPC to another domain be done?
I think you'l have to get it via server side code.
It's the same problem with XMLHttpRequest (Ajax).

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 23 '07 #6
ASM
Tom Cole a écrit :
On Mar 23, 6:40 pm, "Marc" <sorry...@dirtymail.comwrote:
>>So how can RPC to another domain be done?
On the server.

Fair enough.
not so much ...

parent.internal_iframe.location = 'server_one.php';

with file 'server_one.php' :

<?
readfile('http://www.server_one.com/folder/file.htm');
?>
or

parent.internal_iframe.location='servers.php?url=s erver_one.com/folder/file.htm';

with file 'servers.php' :

<?
readfile('http://www.'.$_GET['url']);
?>
--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Mar 24 '07 #7
On Mar 23, 4:23 pm, "Tom Cole" <tco...@gmail.comwrote:
I'am not very sure you'll be authorized to get the content of the iframe ...
especially if this content comes from another domain.

That's what I'm experiencing, I'm getting security exceptions in Opera
and in Firefox. So how can RPC to another domain be done?
see if these help-
http://www.whatwg.org/specs/web-apps...cumentMessages
http://virtuelvis.com/archives/2005/...ment-messaging

http://blog.monstuff.com/archives/000304.html

Mar 24 '07 #8

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

Similar topics

3
by: alejandro.rivero | last post by:
In Mozilla, the following code seems to resize correctly the IFRAME, so no scroll bars: <iframe marginwidth=0 marginheight=0 src=text.html onload="this.height= this.contentDocument.height">...
2
by: Rich | last post by:
Is there any way I can check to see if a document is loaded into the iframe before I call onLoad (sort of an afterLoad). I'm loading up a page into an iframe. But because we use four servers...
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");...
26
by: shlomi.schwartz | last post by:
using this example: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test Page</title> </head>
21
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
7
by: icemtn0611 | last post by:
Is there a way for javascript to detect activity in a child iframe that references a foriegn domain? i.e. It appears that security restrictions prevent events from propagating to the parent. ...
3
by: whatever0 | last post by:
Hi, I'm fairly new to javascript and was hoping i could have a little help... I have a page containing a form and an iframe. The iframe is initially empty (src="about:blank"). The target of...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Mister, any solution about it ? any sample code please ?? thanks in advance
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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,...
0
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...

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.