Applets
The
applets[]
array of
the
Document object
contains objects
that represent the applets embedded in the document with the
<applet>
or
<object>
tag. An applet is a portable,
secure
Java
program that is loaded over the Internet and executed by the web
browser; both
Netscape and Internet Explorer support Java
(although IE 6 no longer includes Java support by default).
As of Netscape 3 and Internet Explorer 3, both browsers allow JavaScript to invoke public methods and read and write the public properties of Java applets. (As we’ll see in Chapter 22, Netscape also supports much richer bidirectional interactions between JavaScript and Java.) All applets have a few standard public methods that they inherit from their superclasses, but the most interesting methods and properties vary on a case-by-case basis. If you are the author of the applet that you want to control from JavaScript, you already know what public methods and properties it defines. If you are not the author, you should consult the applet’s documentation to determine what you can do with it.
Here’s how you might embed a Java applet in a web page with the
<applet>
tag and then invoke the
start( )
and stop( )
methods of
that applet from JavaScript event handlers:
<applet name="animation" code="Animation.class" width="500" height="200"> </applet> <form> <input type="button" value="Start" onclick="document.animation.start( );"> <input type="button" value="Stop" onclick="document.animation.stop( );"> </form>
All applets ...
Get JavaScript: The Definitive Guide, Fourth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.