Calling JS Functions from an applet..

Discussion in 'Javascript' started by SPG, Jun 28, 2004.

  1. SPG

    SPG Guest

    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
     
    SPG, Jun 28, 2004
    #1
    1. Advertising

  2. 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/
     
    Martin Honnen, Jun 28, 2004
    #2
    1. Advertising

  3. SPG

    SPG Guest

    Bingo!

    Thanks, solved my problem!

    Steve
    "Martin Honnen" <> wrote in message
    news:40e03419$...
    >
    >
    > 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, Jun 28, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Xiangliang Meng
    Replies:
    1
    Views:
    1,608
    Victor Bazarov
    Jun 21, 2004
  2. Daniel Vallstrom
    Replies:
    2
    Views:
    1,895
    Kevin Bracey
    Nov 21, 2003
  3. S?ren Gammelmark
    Replies:
    1
    Views:
    1,893
    Eric Sosman
    Jan 7, 2005
  4. Ross A. Finlayson
    Replies:
    19
    Views:
    604
    Keith Thompson
    Mar 10, 2005
  5. SPG
    Replies:
    1
    Views:
    111
Loading...

Share This Page