473,685 Members | 2,976 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
programmaticall y using this:

iframe = document.create Element('IFRAME ');
iframe.width = 0;
iframe.height = 0;
iframe.style.bo rder = 'none';
iframe.id = "internal_frame ";
iframe.name = "internal_frame ";
iframe.src= "blank.html ";
iframe.onload = function() { alert('Somethin g'); };
document.body.a ppendChild(ifra me);

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 9631
ASM
Tom Cole a écrit :
>
and there I am creating the iframe
programmaticall y using this:

iframe = document.create Element('IFRAME ');
iframe.width = 0;
iframe.height = 0;
iframe.style.bo rder = 'none';
iframe.id = "internal_frame ";
iframe.name = "internal_frame ";
iframe.src= "blank.html ";
iframe.onload = function() { alert('Somethin g'); };
document.body.a ppendChild(ifra me);

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.locatio n = 'my_new_file.ht m';
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 <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
wrote:
Tom Cole a écrit :


and there I am creating the iframe
programmaticall y using this:
iframe = document.create Element('IFRAME ');
iframe.width = 0;
iframe.height = 0;
iframe.style.bo rder = 'none';
iframe.id = "internal_frame ";
iframe.name = "internal_frame ";
iframe.src= "blank.html ";
iframe.onload = function() { alert('Somethin g'); };
document.body.a ppendChild(ifra me);
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.locatio n = 'my_new_file.ht m';
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('Somethin g'); };

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.c omwrote in message
news:11******** *************@b 75g2000hsg.goog legroups.com...
On Mar 23, 6:10 pm, ASM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
wrote:
Tom Cole a écrit :
and there I am creating the iframe
programmaticall y using this:
iframe = document.create Element('IFRAME ');
iframe.width = 0;
iframe.height = 0;
iframe.style.bo rder = 'none';
iframe.id = "internal_frame ";
iframe.name = "internal_frame ";
iframe.src= "blank.html ";
iframe.onload = function() { alert('Somethin g'); };
document.body.a ppendChild(ifra me);
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.locatio n = 'my_new_file.ht m';
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('Somethin g'); };

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...@dirty mail.comwrote:
So how can RPC to another domain be done?

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

"Tom Cole" <tco...@gmail.c omwrote in message

news:11******** *************@b 75g2000hsg.goog legroups.com...
On Mar 23, 6:10 pm, ASM <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
wrote:


Tom Cole a écrit :
and there I am creating the iframe
programmaticall y using this:
iframe = document.create Element('IFRAME ');
iframe.width = 0;
iframe.height = 0;
iframe.style.bo rder = 'none';
iframe.id = "internal_frame ";
iframe.name = "internal_frame ";
iframe.src= "blank.html ";
iframe.onload = function() { alert('Somethin g'); };
document.body.a ppendChild(ifra me);
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.locatio n = 'my_new_file.ht m';
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('Somethin g'); };

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 <stephanemoriau x.NoAd...@wanad oo.fr.invalid>
wrote:
>With IE do you get the new file in your iframe ?

Probably better result with :
parent.internal _iframe.locatio n = 'my_new_file.ht m';
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('Somethin g'); };
and ... did you try the foo.location.hr ef 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...@dirty mail.comwrote:
>>So how can RPC to another domain be done?
On the server.

Fair enough.
not so much ...

parent.internal _iframe.locatio n = 'server_one.php ';

with file 'server_one.php ' :

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

parent.internal _iframe.locatio n='servers.php? url=server_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.c omwrote:
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
18699
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"> </iframe> Of course a frameborder=0 can be desiderable too :-)
2
9537
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 which use load balancing, the content isn't specified straight away. Therefore as I'm using onload to resize the iframes scroll bars to the size of the iframe content, I need to wait for this to be loaded first. Is there an alternative to onLoad that...
16
7101
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"); MyDiv.appendChild(iframeObject); var data = "<html><head><title>testing</title></head><body>data</body></html>" iframeObject.contentDocument.open(); iframeObject.contentDocument.writeln(data);
26
3232
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
6137
by: javainfo | last post by:
How can i refresh IFRAME and load data through AJAX?
7
9046
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. I'm simply interested in whether there is user activity in the iframe ... I don't really need the events. I need to timeout the iframe upon a period of inactivity. I thought I might overlap a frame over the iframe, but events don't pass thru .....
3
2960
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 the form is the iframe, so when the form is submitted the iframe loads a page (which is remote and I cannot edit). What i would like to happen is that when the contents of the iframe has finished loading, the page (as in: the entire page) then...
1
5679
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Mister, any solution about it ? any sample code please ?? thanks in advance
0
8577
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
8507
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,...
1
6431
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5792
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
4302
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2938
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1927
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.