Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > IFrame.onload, IE and Remote Scripting

Reply
Thread Tools

IFrame.onload, IE and Remote Scripting

 
 
Tom Cole
Guest
Posts: n/a
 
      03-23-2007
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.

 
Reply With Quote
 
 
 
 
ASM
Guest
Posts: n/a
 
      03-23-2007
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
 
Reply With Quote
 
 
 
 
Tom Cole
Guest
Posts: n/a
 
      03-23-2007
On Mar 23, 6:10 pm, ASM <(E-Mail Removed)>
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 -



 
Reply With Quote
 
Marc
Guest
Posts: n/a
 
      03-23-2007
>So how can RPC to another domain be done?

On the server.

(sorry for the 'top' post)

"Tom Cole" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
On Mar 23, 6:10 pm, ASM <(E-Mail Removed)>
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>


 
Reply With Quote
 
Tom Cole
Guest
Posts: n/a
 
      03-23-2007
On Mar 23, 6:40 pm, "Marc" <(E-Mail Removed)> wrote:
> >So how can RPC to another domain be done?

>
> On the server.


Fair enough.

>
> (sorry for the 'top' post)
>
> "Tom Cole" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ups.com...
> On Mar 23, 6:10 pm, ASM <(E-Mail Removed)>
> 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 -



 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      03-23-2007
Tom Cole a écrit :
> On Mar 23, 6:10 pm, ASM <(E-Mail Removed)>
> 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
 
Reply With Quote
 
ASM
Guest
Posts: n/a
 
      03-24-2007
Tom Cole a écrit :
> On Mar 23, 6:40 pm, "Marc" <(E-Mail Removed)> wrote:
>>> 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
 
Reply With Quote
 
scripts.contact
Guest
Posts: n/a
 
      03-24-2007
On Mar 23, 4:23 pm, "Tom Cole" <(E-Mail Removed)> wrote:

> > 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using a Scripting Language as Your Scripting Language DaveInSidney Python 0 05-09-2005 03:13 AM
Remote Assistance fails to connect, remote remote host name could not be resolved Peter Sale Wireless Networking 1 12-11-2004 09:09 PM
Python is the best and most popular general purpose scripting language; the universal scripting language Ron Stephens Python 23 04-12-2004 05:32 PM
Remote Scripting and URLs Chuck Jungmann Javascript 2 01-13-2004 03:30 PM
Remote Scripting and Sun JVM SW ASP General 6 01-05-2004 08:02 PM



Advertisments