See also: JSV_appletParam

Writes an applet tag (<applet></applet>).

Syntax

JSV_applet(appletAttributes, [appletParam, ...])

Prototype

n/a

Returns

The JSV_applet function returns an APPLET tag and any passed PARAM tags.

Parameters

The JSV_applet function uses the following arguments.

Argument Description
appletAttributes The arguments associated with the APPLET tag, e.g.,
  • The CODE attribute specifies the name of the class file that contains the compiled APPLET subclass.
  • The required WIDTH and HEIGHT attributes define the dimensions of the applet.
See Example for an example of the format of this argument. See Remarks for further information on APPLET arguments.
appletParam Any number of APPLET PARAM tags that are needed to administer the applet. See Example for an example passing the param tags associated with an applet.

Remarks

The APPLET element is used to embed Java applets. It has been deprecated in HTML 4.0 in favor of the more generalized OBJECT element. However, since the few browsers that support OBJECT do so with significant bugs, APPLET is currently a more reliable method of embedding Java applets.

APPLET's CODE attribute specifies the name of the class file that contains the compiled Applet subclass. The value is relative to the URI specified in the CODEBASE attribute, or to the HTML document's base URI if the CODEBASE attribute is not given.

The required WIDTH and HEIGHT attributes define the dimensions of the applet. The value may be given in pixels or as a percentage of the parent element's width or height.

The ALT attribute can be used to give alternate text for browsers that recognize the APPLET element but do not support Java or do not have Java enabled. Authors can also give alternate content between the start and end tags of the APPLET element--a better method than using the ALT attribute since it allows authors to include HTML markup in the alternate content and also works with pre-HTML 3.2 browsers that do not support APPLET.

An APPLET may contain PARAM elements to define applet-specific parameters. PARAM elements should be specified before any other content of the APPLET element.

The ARCHIVE attribute can specify a comma-separated list of archived files (either absolute URIs or URIs relative to the CODEBASE), allowing the browser to download many files with a single connection and hence decreasing the total download time. The standard archive format for Java files is JAR.

Note that some browsers do not support the ARCHIVE attribute, so all necessary files should be available unarchived as well. Other browsers only support a single URI as the ARCHIVE value.

The OBJECT attribute specifies a serialized (saved) representation of an applet. The CODE attribute should not be used if and only if the OBJECT attribute is specified. When the applet is deserialized, its init() method is not invoked, but its start() method is. Sun recommends restraint in using this poorly supported feature.

The ALIGN attribute specifies the alignment of the applet. The values top, middle, and bottom specify the applet's position with respect to surrounding content on its left and right. ALIGN="middle" aligns the center of the applet with the current baseline. To center the applet horizontally on the page, place the applet in a centered block, e.g.,

<P ALIGN="center">
<APPLET CODE="Game.class" WIDTH="300" HEIGHT="100"></APPLET>
</P> 

The other ALIGN values, left and right, specify a floating applet; the applet is placed at the left or right margin and content flows around it. To place content below the applet, use <BR CLEAR=left|right|all> as appropriate.

The vertical-align and float properties of Cascading Style Sheets provide more flexible methods of aligning applets.

The HSPACE and VSPACE attributes allow an author to suggest horizontal gutters and vertical gutters, respectively, around the applet. The value must be in pixels and applies to both sides of the applet. Style sheets provide more flexibility in specifying the space around applets.

See the Web Design Group HTML 4.0 Reference on the applet tag for more information.

Dependencies

n/a

Example

The following lines of code

function paintClock() {
    document.write( 
        JSV_applet(  
                        'codebase="classes" code="JavaClock.class" width="125" height="125"', 
                        JSV_appletParam("delay", "100"),
                        JSV_appletParam("link", "http://java.sun.com/"),
                        JSV_appletParam("border", "5"),
                        JSV_appletParam("nradius", "80"),
                        JSV_appletParam("cfont", "TimesRoman|BOLD|18"),
                        JSV_appletParam("bgcolor", "8080FF"),
                        JSV_appletParam("shcolor", "ff0000"),
                        JSV_appletParam("mhcolor", "00ff00"),
                        JSV_appletParam("hhcolor", "0000ff"),
                        JSV_appletParam("ccolor", "dddddd"),
                        JSV_appletParam("ncolor", "000000")
        )
    );
}

paintClock();

produce