473,287 Members | 1,629 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,287 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 9594
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: 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:
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
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...

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.