HTML The Definitive Guide (131 page)

Read HTML The Definitive Guide Online

Authors: Chuck Musciano Bill Kennedy

BOOK: HTML The Definitive Guide
2.62Mb size Format: txt, pdf, ePub

13.2.2 The Tag

The tag supplies parameters for a containing or tags. (We discuss the deprecated tag in section
Section 13.2.3, "The Tag (Deprecated)".)


Function:

Supply a parameter to an embedded object

Attributes:

ID

NAME

TYPE

VALUE

VALUETYPE

End tag:

None

Contains:

Nothing

Used in:

applet_content

The tag has no content and no end tag. It appears, perhaps with other tags, only between an or tag and its end tag. Use the tag to pass parameters to the embedded object, such as a Java applet, as required for it to function correctly.

13.2.2.1 The name and value attributes
The tag has two required attributes: name and value. You've seen these before with HTML

forms. Together, they define a name/value pair that the browser passes to the applet.

For instance, our clock applet example might let users specify the time zone by which it sets its hour hand. To pass the parameter named "timezone" with the value "EST" to our example applet, specify the parameters as:



Since both attributes had simple strings for values, we did not enclose the values in quotation marks. For values with embedded punctuation and spaces, be sure to include quotes.

The browser will pass the name/value pairs to the applet, but that is no guarantee that the applet is expecting the parameters, that the names and values are correct, or that the applet will even use the parameters. Correct parameter names, including capitalization, and acceptable values are determined by

the applet author. The wise HTML document author will work closely with the applet author or have detailed documentation to ensure that the applet parameters are named correctly and assigned valid values.

13.2.2.2 The type and valuetype attributes
Use the type and valuetype attributes to define the type of the parameter the browser passes to the embedded object and how that object is to interpret the value. The valuetype attribute can have one of three values: data, ref, or object. The value data indicates that the parameter value is a simple string. This is the default value. Using ref indicates that the value is a URL of some other resource on the web. Finally, object indicates that the value is the name of another embedded object in the current document. This may be needed to support inter-object communication within an HTML document.

The value of the type attribute is the MIME media type of the value of the parameter. This is usually of no significance when the parameter value is a simple string, but can be important when the value is actually a URL pointing to some other object on the Web. In those cases, the embedded object may need to know the MIME type of the object in order to use it correctly. For example, this parameter tells the embedded object that the parameter is actually the URL of a Microsoft Word document:
13.2.3 The Tag (Deprecated)
Use the tag within your HTML document to download and execute an applet. Also, use the tag to define a region within the document display for the applet's display area. You may supply alternative content within the tag for display by browsers that do not support applets.


Function:

Insert an application into the current text flow Attributes:

ALIGN ID

ALT MAYSCRIPT

ARCHIVE NAME

CLASS OBJECT

CODE STYLE

CODEBASE TITLE

HEIGHT VSPACE

HSPACE WIDTH

End tag:

; never omitted

Contains:

applet_content

Used in:

text

Most applets require one or more parameters that you supply in the HTML document to control their execution. Put these parameters between the tag and its corresponding end tag using the tag. The browser passes the document-specific parameters to the applet at time of
execution. [The Tag, 13.2.2]

The tag has been deprecated in the HTML 4.0 standard in deference to the generalized tag, which can do the same as and much more. Nonetheless, is a popular tag and remains well supported by the popular browsers. Don't expect that it will go away any time soon, but do realize that will go away.

13.2.3.1 Applet rendering

The browser creates an applet's display region in the containing text flow exactly like an inline image: without line breaks and as a single large entity. The browser downloads and executes the applet just after download and display of the HTML document, and continues execution until the code terminates itself or when the user stops viewing the page containing the applet.

13.2.3.2 The align attribute

Like an image, you may control the alignment of an applet's display region with respect to its surrounding text. Like with the tag, set the align attribute's value to top, texttop, middle, absmiddle, baseline, bottom, or absbottom, as well as left and right alignments for wraparound content.

[The Tag, 5.2.6]

13.2.3.3 The alt attribute

The alt attribute gives you a way to tell users gracefully that something is missing if, for some reason, the applet cannot or will not execute on their computer. Its value is a quote-enclosed message string that, like the alt attribute for images, gets displayed in lieu of the applet itself.

The alt message is only for browsers that support applets. See section 13.2.1.15 to find out how to inform users of applet-incapable browsers why they can't view an applet.

13.2.3.4 The archive attribute

The archive attribute lets you collect common Java classes into a single library that is cached on the user's local disk. Once cached, the browser doesn't need to use the network to access an applet; it retrieves the software from the local cache, thereby reducing the inherent delays of additional network activity to load the class.

The value of the archive attribute is a URL identifying the archive file. The suffix of the archive filename may be either
.zip
or
.jar
. Archived
.zip
files are in the familiar ZIP archive format, generated by PKZIP and many other utilities. Archived
.jar
files are in the new Java archive format; currently, support for
.jar
files is spotty at best, but they will become more widespread. Archived
.jar
files support compression and some advanced features like digital signatures.

You may use the archive attribute with any tag, even if the class referenced by the tag's code attribute does not exist in the archive. If the class is not found in the archive, the browser simply attempts to retrieve the class relative to the document URL or the codebase URL, if specified.

13.2.3.5 The code and codebase attributes
The code attribute is required. Use code to specify the filename, not the URL, of the Java class to be executed by the browser. Like , make the search relative to another storage location by using the codebase
attribute described in section Section 13.2.1.2, "The codebase attribute"
or an archive, as described in section
Section 13.2.3.4, "The archive attribute". Also, the extension suffix of the filename

should be
.class
. If you don't include the suffix, some browsers will append
.class
automatically when searching for the applet.

Here is our infamous clock example rewritten as an :

which the browser will retrieve and display from: http://www.kumquat.com/classes/clock.class
13.2.3.6 The name attribute

The name attribute lets you supply a unique name for this instance of the code class - the copy of the applet that runs on the individual user's computer. Like other named elements in your HTML document, providing a name for the applet lets other parts of your HTML document, including other applets, reference and interact with this one, such as sharing computed results.

13.2.3.7 The height, hspace, vspace, and width attributes
Use the height and width attributes (identical to the counterparts for the and tags) to define the size of the applet's display region in the document. Use hspace and vspace to interpose some empty space around the applet region and thereby set it off from the text. They all accept values indicating the size of the region in pixels.
[The height and width attributes, 5.2.6.10]

13.2.3.8 The mayscript attribute

The mayscript attribute, supported only by Netscape, indicates that the Java applet will be accessing JavaScript features within the browser. Normally, Java applets attempting to access JavaScript cause a browser error. If your applets access JavaScript, you must specify mayscript in the tag.

13.2.3.9 The title attribute

The value of this attribute is a quoted string, which is used by Internet Explorer to provide a title, if necessary, for the applet. This attribute is not supported by Netscape.

13.2.3.10 The object attribute

This unfortunately named attribute and its string value reference the name of the resource that contains a serialized version of the applet. How and what it does is an enigma; none of the popular browsers support it.

Other books

Althea by Madeleine E. Robins
The Clue in the Diary by Carolyn G. Keene
Las nieblas de Avalón by Marion Zimmer Bradley
Camelot's Blood by Sarah Zettel
Nurse Lang by Jean S. Macleod
Living in Syn by Bobby Draughon
Agatha & Savannah Bay by Marguerite Duras

© 100 Vampire Novels China Edition 2015 - 2024    Contact for me [email protected]