<APPLET> | NN 2 IE 3 HTML 3.2
<APPLET>...</APPLET> | HTML End Tag: Required
You can embed an executable chunk of Java code in an HTML document in the form of an applet. An applet occupies a rectangular area of the page, even if it is only one-pixel square. An applet may require that some initial values be set from the HTML document. One or more param elements can be used to pass parameters to the applet before the applet starts running (provided the applet is written to accept these parameters). param elements go between the start and end tags of an applet element. Applets are compiled by their authors into class files (filename suffix .class). An applet class file must be in the same directory as, or a subdirectory of, the HTML document that loads the applet. Key attributes of the applet element direct the browser to load a particular class file from the necessary subdirectory. All user interface design for the applet is programmed into the applet in the Java language. One of the roles of attributes in the applet element is to define the size and other geographical properties of the applet for its rendering on the page. Recent browsers allow JavaScript scripts to communicate with the applet, as well as allowing applets to access document elements (not implemented in Netscape 6). Note that HTML 4 deprecates the applet element in favor of the more generic object element. Support for embedding applets via the object element is still spotty. Browser support for the applet element will continue for some time to come, however.
Example
    <APPLET code="simpleClock.class" name="myClock" width="400" height="50">
    <PARAM name="bgColor" value="black">
    <PARAM name="fgColor" value="yellow">
    </APPLET>
Object Model Reference
    [window.]document.applets[i]
    [window.]document.appletName
    [window.]document.getElementById(elementID)
Element-Specific Attributes
align | alt | archive | code | codebase
datafld | datasrc | height | hspace | mayscript
name | object | src | vspace | width
Element-Specific Event Handler Attributes
Handler | NN | IE | HTML
onafterupdate | n/a | 4 | n/a
onbeforeupdate | n/a | 4 | n/a
ondataavailable | n/a | 4 | n/a
ondatasetchanged | n/a | 4 | n/a
ondatasetcomplete | n/a | 4 | n/a
onerrorupdate | n/a | 4 | n/a
onrowenter | n/a | 4 | n/a
onrowexit | n/a | 4 | n/a

align | NN 2 IE 3 HTML 3.2
align="alignmentConstant" | Optional
The align attribute determines how the rectangle of the applet aligns within the context of surrounding content. See the Section 8.1.5, earlier in this chapter for description of the possibilities defined in both Navigator and Internet Explorer for this attribute.
Example
    <APPLET code="simpleClock.class" name="myClock" align="absmiddle"
    width="400" height="50"></APPLET>
Value
Case-insensitive constant value.
Default
bottom
Object Model Reference
    [window.]document.applets[i].align
    [window.]document.appletName.align
    [window.]document.getElementById(elementID).align

alt | NN 3 IE 3 HTML 3.2
alt="textMessage" | Optional
If a browser does not have the facilities to load and run Java applets or if the browser has Java support turned off in its preferences, the text assigned to the alt attribute is supposed to display in the document where the applet element's tag appears. Typically, this text provides advice on what the page visitor is missing by not being able to load the Java applet. Unlike the noscript or noframes elements, there is no corresponding element for an absent Java applet capability. In practice, browsers don't necessarily display this message for applets that fail to load for a variety of reasons.
Example
    <APPLET code="simpleClock.class" name="myClock" align="absmiddle"
    alt="A Java clock applet." width="400" height="50"></APPLET>
Value
Any quoted string of characters.
Default
None.

archive | NN 3 IE 6 HTML 4
archive="archiveFileURL" | Optional
The precise meaning of the archive attribute varies between the generic HTML 4 recommendation and Netscape's specific implementation. The basic idea behind Netscape's archive attribute is that an author can package multiple class files into a single uncompressed .zip archive file and let the browser load the entire set of classes at one time. This can offer a performance improvement over loading just the main class file (specified by the code attribute) and then letting the class loader fetch each additional class file as needed. In addition to specifying the archive attribute, be sure to include a code attribute that names the main class to load. Navigator first looks for the presence of that class file in the archive. If the file is missing from the archive, Navigator loads the code class file separately. (That class may then load additional supporting class files individually.) Navigator requires that the archive file have a .zip filename extension. The URL must also be relative to the codebase location. The HTML specification allows multiple URLs to be specified (in a space-delimited list) for additional class or other resource files. This design anticipates the use of the same attribute with the object element, which the W3C has deemed the successor to the applet element. IE 6 supports the existence of the attribute for compatibility only, but it is not operable.
Example
    <APPLET code="ScriptableClock.class" archive="myClock.zip" width="400" height="50">
    </APPLET>
Value
Case-sensitive URI.
Default
None.
Object Model Reference
    [window.]document.applets[i].archive
    [window.]document.appletName.archive
    [window.]document.getElementById(elementID).archive

code | NN 2 IE 3 HTML 3.2
code="fileName.class" | Required
The name of the main class file that starts and runs the applet. If the codebase attribute is not specified, the code attribute must include a path from the directory that stores the HTML document loading the applet. You might get away with omitting the .class filename extension, but don't take any chances: be complete with the class name. Most servers are case-sensitive, so also match case of the actual class filename.
Example
    <APPLET code="applets/ScriptableClock.class" width="400" height="50">
    </APPLET>
Value
Case-sensitive .class filename or complete path relative to the HTML document.
Default
None.
Object Model Reference
    [window.]document.applets[i].code
    [window.]document.appletName.code
    [window.]document.getElementById(elementID).code

codebase | NN 2 IE 3 HTML 3.2
codebase="path" | Optional
Path to the directory holding the class file designated in either the code or archive attribute. The codebase attribute does not name the class file, just the path. You can make this attribute a complete URL to the directory, but don't try to access a codebase outside of the domain of the current document: security restrictions may prevent the class from loading. A full path and filename can be set together in the code or object attribute, eliminating the need for the codebase attribute setting.
Example
    <APPLET code="ScriptableClock.class" codebase="applets/" width="400" height="50">
    </APPLET>
Value
Case-sensitive pathname, usually relative to the directory storing the current HTML document.
Default
None.
Object Model Reference
    [window.]document.applets[i].codeBase
    [window.]document.appletName.codeBase
    [window.]document.getElementById(elementID).codeBase

datafld, datasrc |
See the param element for IE data binding to Java applets.

height, width | NN 2 IE 3 HTML 3.2
width="pixels" height="pixels" | Required
The size that a Java applet occupies in a document is governed by the height and width attribute settings. Some browser versions might allow you to get away without assigning these attributes, letting the applet's own user interface design determine the height and width of its visible rectangle. As with images, however, it is more efficient for the browser's rendering engine when you explicitly specify the object's dimensions. Make a habit of supplying these values for all applets, as you should for all images or other visible external objects.
Example
    <APPLET code="ScriptableClock.class" width="400" height="50"></APPLET>
Value
Positive integer pixel values. You cannot entirely hide an applet by setting values to zero, but you can reduce its height and width to one pixel in each dimension. If you want to hide an applet, do so with DHTML by setting its positioning display attribute to none.
Default
None.
Object Model Reference
    [window.]document.applets[i].height
    [window.]document.appletName.height
    [window.]document.getElementById(elementID).height
    [window.]document.applets[i].width
    [window.]document.appletName.width
    [window.]document.getElementById(elementID).width

hspace, vspace | NN 2 IE 3 HTML 3.2
hspace="pixels" vspace="pixels" | Optional
You can put some empty space ("air") between an applet and any surrounding content by assigning pixel values to the hspace and vspace attributes. The vspace attribute governs space above and below the applet; the hspace attribute governs space to the left and right of the applet. For browsers that are style sheet savvy, you are perhaps better served by using the padding and/or margin style attributes to gain control down to individual sides, if you so desire.
Example
    <APPLET code="ScriptableClock.class" width="400" height="50" hspace="3" vspace="4">
    </APPLET>
Value
Positive integer pixel values (optionally quoted).
Default
0
Object Model Reference
    [window.]document.applets[i].hspace
    [window.]document.appletName.hspace
    [window.]document.getElementById(elementID).hspace
    [window.]document.applets[i].vspace
    [window.]document.appletName.vspace
    [window.]document.getElementById(elementID).vspace

id | NN n/a IE 4 HTML 4
id="elementIdentifier" | Optional
A unique identifier that distinguishes this element from all the rest in the document. Can be used to associate a single element with a style rule naming this attribute value as an ID selector. An element can have an ID assigned for uniqueness as well as a class for inclusion within a group. See Chapter 3. If you assign an id attribute and not a name attribute, the value of the id attribute can be used as the applet's name in script reference forms that use the element name (document.appletName).
Example
    <APPLET id="clocker" code="ScriptableClock.class" width="400" height="50">
    </APPLET>
Value
Case-sensitive identifier.
Default
None.
Object Model Reference
    [window.]document.applets[i].id
    [window.]document.appletName.id
    [window.]document.getElementById(elementID).id

mayscript | NN 3 IE 4 HTML n/a
mayscript | Optional
Navigator 3 introduced a technology called LiveConnect, which allowed scripts to communicate with Java applets and vice versa (not yet implemented in Mozilla-based browsers). For security reasons, an applet's communications facilities with scripts must be explicitly switched on by the page author. By adding the mayscript attribute to the applet's tag, an applet that is written to take advantage of the document objects and scripts can address those items. In other words, the HTML is granting the applet the ability to reach scripts in the document. This attribute is a simple switch: when the attribute name is present, it is turned on. One more step is required for an applet to communicate with JavaScript. The applet code must import a special Netscape class called JSObject.class. This class file and its companion exception class are built into the Java support in the Windows version of Internet Explorer 4 and later. Although the execution is not perfect in IE, applets can perform basic communication with scripts.
Example
    <APPLET code="ScriptableClock.class" width="400" height="50" mayscript>
    </APPLET>
Value
No value assigned to the attribute. The presence of the attribute name sets turns on applet-to-script communication.
Default
Off.

name | NN 2 IE 3 HTML 3.2
name="elementIdentifier" | Optional
If you are scripting an applet, it is usually more convenient to create a reference to the applet by using a unique name you assign to the applet. Then, if you edit the page and move or delete multiple applets on the page, you do not have to worry about adjusting index values to array-style references. In IE 4 and later, you have the option of omitting the name attribute and using the id attribute value in script references to the applet object.
Example
    <APPLET name="clock2" code="ScriptableClock.class" width="400" height="50">
    </APPLET>
Value
Case-sensitive identifier.
Default
None.
Object Model Reference
    [window.]document.applets[i].name
    [window.]document.appletName.name
    [window.]document.getElementById(elementID).name

object | NN 6 IE n/a HTML 4
object="filename" | Optional
Reference to the name of the file (relative to the codebase URI) that preserves the applet's state between sessions. When supported properly, this attribute replaces the code attribute, and the data file points to the applet's startup class file.
Example
    <APPLET name="clock2" object="clockData.dat" width="400" height="50">
    </APPLET>
Value
Case-sensitive filename.
Default
None.
Object Model Reference
    [window.]document.applets[i].object
    [window.]document.appletName.object
    [window.]document.getElementById(elementID).object

src | NN n/a IE 4 HTML n/a
src="URL" | Optional
Internet Explorer defines this attribute as the URL for an "associated file." This may be the same as the archive attribute defined in HTML and Navigator specifications. The src attribute is not a substitute for the code and/or codebase attributes.
Value
A complete or relative URL.
Default
None.
Object Model Reference
    [window.]document.applets[i].src
    [window.]document.appletName.src
    [window.]document.getElementById(elementID).aex

vspace |
See hspace.

width |
See height.