Calling JS Functions from an applet..

S

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
 
M

Martin Honnen

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

SPG

Bingo!

Thanks, solved my problem!

Steve
Martin Honnen said:
SPG wrote:



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');


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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top