Calling Java method from Javascript

Discussion in 'Javascript' started by Neil Cherry, Oct 8, 2005.

  1. Neil Cherry

    Neil Cherry Guest

    I've done a fair amount of searching on this subject and I can call
    my Java methods with Javascript if I use the <applet></applet> tags
    but when I switch over to <object></object> tags I'm not longer able
    to call my Java method, instead I get:

    Error: document.CameraViewer.setInterval is not a function

    How does one use the object tags and call Java methods?

    --
    Linux Home Automation Neil Cherry
    http://home.comcast.net/~ncherry/ (Text only)
    http://hcs.sourceforge.net/ (HCS II)
    http://linuxha.blogspot.com/ My HA Blog
    Neil Cherry, Oct 8, 2005
    #1
    1. Advertising

  2. Neil Cherry wrote:

    > I've done a fair amount of searching on this subject and I can call
    > my Java methods with Javascript if I use the <applet></applet> tags
    > but when I switch over to <object></object> tags I'm not longer able
    > to call my Java method, instead I get:
    >
    > Error: document.CameraViewer.setInterval is not a function


    Use
    <object id="applet1" ...></object>
    then try e.g.
    var applet = document.getElementById('applet1');
    if (applet && typeof applet.publicJavaMethodName != 'undefined') {
    // now call method e.g.
    applet.publicJavaMethodName();
    }

    --

    Martin Honnen
    http://JavaScript.FAQTs.com/
    Martin Honnen, Oct 8, 2005
    #2
    1. Advertising

  3. Neil Cherry

    Neil Cherry Guest

    On Sat, 08 Oct 2005 19:51:49 +0200, Martin Honnen wrote:
    >
    >
    > Neil Cherry wrote:
    >
    >> I've done a fair amount of searching on this subject and I can call
    >> my Java methods with Javascript if I use the <applet></applet> tags
    >> but when I switch over to <object></object> tags I'm not longer able
    >> to call my Java method, instead I get:
    >>
    >> Error: document.CameraViewer.setInterval is not a function

    >
    > Use
    > <object id="applet1" ...></object>
    > then try e.g.
    > var applet = document.getElementById('applet1');
    > if (applet && typeof applet.publicJavaMethodName != 'undefined') {
    > // now call method e.g.
    > applet.publicJavaMethodName();
    > }


    Thanks, initially this didn't help. It turned out I had written the
    <object></object> section incorrectly and ended up with an object
    inside an object with the same name. I reordered it and the code
    sample you provided works fine. Thanks.

    --
    Linux Home Automation Neil Cherry
    http://home.comcast.net/~ncherry/ (Text only)
    http://hcs.sourceforge.net/ (HCS II)
    http://linuxha.blogspot.com/ My HA Blog
    Neil Cherry, Oct 9, 2005
    #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. Jabel D. Morales - VMan of Mana

    Problems with JNI: calling a Java method from native method.

    Jabel D. Morales - VMan of Mana, Aug 1, 2003, in forum: Java
    Replies:
    1
    Views:
    4,771
    Joseph Millar
    Aug 1, 2003
  2. Replies:
    1
    Views:
    618
    Andrew Thompson
    Jan 28, 2007
  3. sck10
    Replies:
    0
    Views:
    354
    sck10
    Mar 15, 2007
  4. Eyal
    Replies:
    2
    Views:
    481
  5. why-em-jay

    Calling a method of the calling object ...

    why-em-jay, Sep 15, 2005, in forum: Perl Misc
    Replies:
    3
    Views:
    176
    Anno Siegel
    Sep 15, 2005
Loading...

Share This Page