![]() |
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 |
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/ |
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.