Calling JS Functions from an applet..

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • SPG

    #1

    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

    #2
    Re: Calling JS Functions from an applet..



    SPG wrote:

    [color=blue]
    > 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.[/color]

    If script in page A opens page B make sure you store the window
    reference in a global variable:
    var win;
    win = window.open('pa geB.html', 'winB');
    [color=blue]
    > 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?[/color]

    then in the applet you should be able to access the variable win as a
    member of
    JSObject window = getWindow(this) ;
    JSObject win = window.getMembe r("win");
    win.call("funct ionName", 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/

    Comment

    • SPG

      #3
      Re: Calling JS Functions from an applet..

      Bingo!

      Thanks, solved my problem!

      Steve
      "Martin Honnen" <mahotrash@yaho o.de> wrote in message
      news:40e03419$1 @olaf.komtel.ne t...[color=blue]
      >
      >
      > SPG wrote:
      >
      >[color=green]
      > > I have a requirement to call a method on a page from an applet that is[/color][/color]
      not[color=blue][color=green]
      > > the page that owns the applet..
      > >
      > > For example.
      > >
      > > Page A has the applet.
      > > It opens page B.[/color]
      >
      > If script in page A opens page B make sure you store the window
      > reference in a global variable:
      > var win;
      > win = window.open('pa geB.html', 'winB');
      >[color=green]
      > > Something happens that makes the applet call a method (Javascript).
      > >
      > > I need to be able to call method DoSomething() in Page B from the[/color][/color]
      applet.[color=blue][color=green]
      > >
      > > I know how to call a method on the main page by using the JSObject[/color][/color]
      returned[color=blue][color=green]
      > > from getWindow(this) ; in the applet.
      > >
      > > Is there a way I can pass the reference of the new spawned window into[/color][/color]
      the[color=blue][color=green]
      > > applet so I can then call the method on this page?[/color]
      >
      > then in the applet you should be able to access the variable win as a
      > member of
      > JSObject window = getWindow(this) ;
      > JSObject win = window.getMembe r("win");
      > win.call("funct ionName", 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/
      >[/color]


      Comment

      Working...