471,092 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,092 software developers and data experts.

Calling JS Functions from an applet..

SPG
Hi,

I have a requirement to call a method on a page from an applet that is not
the page that owns the applet..

For example.

Page A has the applet.
It opens page B.

Something happens that makes the applet call a method (Javascript).

I need to be able to call method DoSomething() in Page B from the applet.

I know how to call a method on the main page by using the JSObject returned
from getWindow(this); in the applet.

Is there a way I can pass the reference of the new spawned window into the
applet so I can then call the method on this page?

Cheers,

Steve
Jul 23 '05 #1
2 1806


SPG wrote:

I have a requirement to call a method on a page from an applet that is not
the page that owns the applet..

For example.

Page A has the applet.
It opens page B.
If script in page A opens page B make sure you store the window
reference in a global variable:
var win;
win = window.open('pageB.html', 'winB');
Something happens that makes the applet call a method (Javascript).

I need to be able to call method DoSomething() in Page B from the applet.

I know how to call a method on the main page by using the JSObject returned
from getWindow(this); in the applet.

Is there a way I can pass the reference of the new spawned window into the
applet so I can then call the method on this page?


then in the applet you should be able to access the variable win as a
member of
JSObject window = getWindow(this);
JSObject win = window.getMember("win");
win.call("functionName", arg)
Of course the usual JavaScript restrictions of same origin policy will
apply so page A and B should come from the same server.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #2
SPG
Bingo!

Thanks, solved my problem!

Steve
"Martin Honnen" <ma*******@yahoo.de> wrote in message
news:40********@olaf.komtel.net...


SPG wrote:

I have a requirement to call a method on a page from an applet that is not the page that owns the applet..

For example.

Page A has the applet.
It opens page B.


If script in page A opens page B make sure you store the window
reference in a global variable:
var win;
win = window.open('pageB.html', 'winB');
Something happens that makes the applet call a method (Javascript).

I need to be able to call method DoSomething() in Page B from the applet.
I know how to call a method on the main page by using the JSObject returned from getWindow(this); in the applet.

Is there a way I can pass the reference of the new spawned window into the applet so I can then call the method on this page?


then in the applet you should be able to access the variable win as a
member of
JSObject window = getWindow(this);
JSObject win = window.getMember("win");
win.call("functionName", arg)
Of course the usual JavaScript restrictions of same origin policy will
apply so page A and B should come from the same server.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Rowland | last post: by
3 posts views Thread by Jon-Paul Dobson | last post: by
2 posts views Thread by Blondie21 | last post: by
2 posts views Thread by Neil Cherry | last post: by
3 posts views Thread by Jakub Gutkowski | last post: by

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.