Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    May 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Manipulating Java using JavaScript

    Hello,

    I've tried to invoke the public method of an applet as following:

    <applet id="myApplet" ...></applet>
    <script>
    var returnValue = myApplet.thePublicMethod();
    alert( returnValue );
    </script>

    however, it seems doesn't work??

    I'm wondering if the pervious code fragment is actually the right way to invoke the desired method? If not, how to accomplish the task?

    OS: Windows2000
    Browser: MSIE6
    Plug-in: Java Plug-in 1.3.1_01 (enabled)

    Thanks for any help.
    http://gojijuiceinfo.org/blog/

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,240
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

  • #3
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    There are some browser differences when scripting applets - but I'm pretty sure that using an id is incorrect. Have you tried

    Code:
    <applet name="myApplet" ...></applet>
    <script>
    var returnValue = document.myApplet.thePublicMethod();
    alert( returnValue );

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,240
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    My (limited) understanding is that the applet must have both a name and an identical id (also with regard to case) which Javascript requires to be able to send text to the applet.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •