Applet Scripting
JavaScript can execute methods in an Applet and also retrieve
data from an Applet.
Warning: MS JVM (Microsoft's)
vs Sun's JVM & applets. The statements below have been tested with IE
v6.0.
- Java Applets compiled with SDK 1.5 will not work with MS JVM. You
will need to use Sun's JVM.
- MS JVM (Microsoft's Java
Virtual Machine) is based on API 1.1.6
- Java Applets compiled with JDK 1.2 will work with MS JVM provided that
you just use API 1.1 calls.
Example: JavaScript executes a public Applet method
Applet (Compiled with J2SE 1.2) -
Works with MS JVM & Sun's JVM
document.myApplet_orig1.newText( "Hello World" )
Applet (Compiled with J2SE 1.5) - Only works with Sun's
JVM.
If you use MS JVM you will get the following :
- JavaScript error: "Error: Object
doesn't support this property or method")
- Java Console Error:
Error loading class: Applet1
java.lang.NoClassDefFoundError
java.lang.ClassNotFoundException: Applet1
document.myApplet_orig1.newText( "Hello World" )
Example: JavaScript get data from public Applet method
Testing links:
Send a default text message to all Applets.
- Applet #1
- Applet #2
- Applet #3
Applet #1
Applet #2
Applet #3
Testing URLs:
http://localhost/michael-thomas/tech/java/javaadvanced/appletsjavascript/appletsjavascript.htm
http://www.michael-thomas.com/tech/java/javaadvanced/appletsjavascript/appletsjavascript.htm