Click to See Complete Forum and Search --> : Calling Applet method
kopite
04-27-2003, 02:50 PM
Hi,
Have a problem, I want to call a class method in an Applet.
html extract...
<form id="myForm">
<OBJECT id="myappletid">
<PARAM name="code" value="myApplet.class">
</OBJECT>
</form>
My javascript is like this but it doesnt make the call
a) document.myForm.myappletid.myMethod();
b) document.myForm.myappletid.myApplet.myMethod();
Firstly I tried (a) but that failed (src: http://java.sun.com/j2se/1.4.1/docs/guide/plugin/developer_guide/js_java.html). Then I tried (b) but neither work.
All the paths and names are correct.
Help!
viravan
04-27-2003, 04:36 PM
Using the <OBJECT> means that your applet will only work on IE (not on NN).....it doesn't look quite right. Have you ever heard of the HTMLCONVERTER program? if so, include the following line in your HTML file and run the HTMLCONVERTER that comes with your SDK:
....
<APPLET CODE = "myApplet" CODEBASE = "." NAME = "myappletid" MAYSCRIPT></APPLET>
Then see if it works by referencing the public method as follows:
document.myappletid.myMethod();
If it still doesn't work, I need to know:
1) Whick JDK did you use to compile the applet? Type:
java -version
at the command prompt and paste the result here.
2) Will your applet run with native JVM or does it require a plugin?
:)
V.V.
khalidali63
04-27-2003, 11:37 PM
Check thi slink out,
I wrote a simple applet to display the functionality involved in communication between HTML?javaScript and applet functions.
http://68.145.35.86/skills/javascripts/applets/AppletJavaScriptInteraction.html
viravan
04-28-2003, 08:55 AM
Hi khalidali63:
Check thi slink out,
It doesn't work on my Windows XP/IE6/jre1.4.2beta combination.
The JavaScript error message I received is when I tried to send text to applet:
Line:22
Char:2
Error: Object doesn't support this property or method
When I tried to get text from applet, the error is on line 26, char 3!
It works fine with NN7.02.
Seems like you need the MAYSCRIPT in the <APPLET> tag as well. You might want to put your html file thru the HTMLCONVERTER.
:)
V.V.
khalidali63
04-28-2003, 09:03 AM
Originally posted by viravan
Line:22
Char:2
Error: Object doesn't support this property or method
V.V.
Sounds like problem with your IE pluggin,since it worked on NS
Originally posted by viravan
[B]MAYSCRIPT in the <APPLET> tag as well. You might want to put your html file thru the HTMLCONVERTER.
:)
V.V.
Good suggestion...thanks
:D
kopite
04-28-2003, 09:12 AM
I managed to get it working in the end with the original segment of code, I guess there was another rogue piece of code in my script:
document.myForm.myappletid.myMethod();
This is on an IE v6, XP box
viravan
04-28-2003, 09:34 AM
Sounds like problem with your IE pluggin,since it worked on NS
If so, I don't know what it is... When I installed the humongous (190mb) jre1.4.2beta, I checked both IE and NN. Furthermore, my IE is set to use Sun's plugin.
Applet is no fun, check out the link shown below:
http://www.microsoft.com/java/
:)
V.V.