View Full Version : Manipulating Java using JavaScript

05-14-2009, 09:29 AM

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

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

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.

Philip M
05-14-2009, 11:04 AM
This is the JavaScript forum. Java and Javascript are entirely different programming languages, in spite of the confusingly similar names.

05-14-2009, 11:20 AM
There are some browser differences when scripting applets - but I'm pretty sure that using an id is incorrect. Have you tried

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

Philip M
05-14-2009, 12:11 PM
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.