Main Page

Java Applets

} else {
//no way to detect!
return false;
This function uses object detection to determine which methodology to use. If
available, then the function checks for an installed plugin using Netscape-style plugin detection. If, on
the other hand, it’s possible to create
objects, it uses the IE-style of detection. If neither
of these options is available (which isn’t very likely), the function just returns
To detect specific plugins, you can customize this algorithm and create a whole host of plugin detection
Java Applets
The oldest form of plugin, the Java applet has recently been redefined to work with the generic browser
plugin framework. Previously, applets had to be loaded using the
element. HTML 4.0 depre-
, favoring
as the sole means for embedding plugins. To aid in this move,
Sun Microsystems created the Java Plugin, which is included as part of the Java Runtime Environment
(JRE) and is available at
Embedding applets
Embedding an applet requires you to use the nonstandard
property of
to specify the
class to load. Although all browsers should work when using
for the same purpose, the reality is
that support isn’t yet universal. So, in the interest of cross-browser compatibility, it’s best to use
in this way:
<object type=”application/x-java-applet”
code=”ExampleApplet.class” width=”100” height=”100” id=”ExampleApplet”>
Note the mime type for Java applets is
. By specifying this, you are sure
that the browser will use the most appropriate (and available) version of the Java plugin. You can
optionally specify the exact version required by adding it to the end of the mime type. For example, to
specify version 1.4.2 (from JRE 1.4.2), add
<object type=”application/x-java-applet;jpi-version=1.4.2”
code=”ExampleApplet.class” width=”100” height=”100” id=”ExampleApplet”>
Macromedia provides a Flash Detection Kit, available at
/, which can be used to produce
cross-browser HTML and JavaScript for embedding Flash movies.
Interacting with Plugins
21_579088 ch18.qxd 3/28/05 11:43 AM Page 543

JavaScript EditorFree JavaScript Editor     Ajax Editor