Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   Calling JS Functions from an applet.. (http://www.velocityreviews.com/forums/t878126-calling-js-functions-from-an-applet.html)

SPG 06-28-2004 02:33 PM

Calling JS Functions from an applet..
 
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



Martin Honnen 06-28-2004 03:06 PM

Re: Calling JS Functions from an applet..
 


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/


SPG 06-28-2004 03:28 PM

Re: Calling JS Functions from an applet..
 
Bingo!

Thanks, solved my problem!

Steve
"Martin Honnen" <mahotrash@yahoo.de> wrote in message
news:40e03419$1@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/
>





All times are GMT. The time now is 12:36 PM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57