Tutorials Bugs Masterclass Free stuff Test pages Proposals

Basic concepts

Advanced concepts

RichInStyle.com HTML 4 guide - Objects

Contents

Introduction to objects

Object attributes

Other attributes for <OBJECT>

Browsers that cannot render the contents of <OBJECT>s

<PARAM>

Using declared OBJECTs

Embedding HTML

Introduction to objects

Although images were discussed earlier on in this HTML tutorial, they represent a limited subset of objects. In a nutshell, objects are instances of external data inserted in a page. They are designed to provide an infinitely extensible means of inserting content. Here's an example

<OBJECT data="image.jpg" type="image/jpeg"> An image </OBJECT>

And its IMG equivalent:

<IMG alt="An image" src="image.jpg">

Object attributes

Two attributes are sufficient for any object:

  1. classid
  2. data

The data attribute is used to specify the location of object data. Object data include things such as images.

The classid attribute specifies the location of the object's implemenation. Object implementations include things like applets - whereas data is the subject of an implementation and has a subservient role, the classid attribute specifies the thing that can use the data. E.g.:

<OBJECT classid="http://www.foo.com/applet.java">

Note that objects frequently do not require both data and classid - one is usually all that is needed. For example, with images, the implementation can usually be done by the browser, so all that is needed is the data.

Conversely, many implementations do not require any data; for example, a clock applet probably wouldn't need any extra data.

Objects may appear both in the <HEAD> and <BODY> of documents. However, <OBJECT>s in the <HEAD> should not produce rendered content.

Other attributes for <OBJECT>

Certain other attributes also perform a useful function:

  1. standby - this gives a text message to be used while rendering the document; for example, <OBJECT standby="Please wait">
  2. archive - the archive attribute is used to specify a space-separated list of things that the object will use. Use of this attribute will reduce waiting time. E.g., <OBJECT archive="image.gif">. This is in addition to classid and data.
  3. codebase - this gives a base path with which to resolve relative URIs specified on archive, data or classid
  4. type - this specifies the content type of data specified via the data attribute. For example, <OBJECT type="image/jpeg" data="image.jpeg">. Use of this attribute is recommended if data is used to avoid loading unsupported objects.
  5. codetype - this specifies the content type of data downloaded via classid. It is recommended to avoid loading unsupported data.
  6. title - this gives a title, useful for tooltips
  7. declare - this attribute declares the OBJECT but does not run it. E.g., <OBJECT
  8. id - this gives the <OBJECT> an id for referencing purposes

Browsers that cannot render the content of <OBJECT>s

Browsers that can't render the content of <OBJECT> elements will try the content. E.g.:

<OBJECT classid="java.jar">
  <OBJECT title="Will only be rendered if the java can't be used" type="image/gif" data="image.gif">
    Will only be rendered if the image and java can't be used.
  </OBJECT>
</OBJECT>

You should always include alternate content inside <OBJECT> for non-object supporting browsers.

<PARAM>

The <PARAM> element is used to specify parameters to be passed to an OBJECT. For example:

<OBJECT classid="java.jar">
<PARAM name="size" value="100" valuetype="data">
Alternate content here
</OBJECT>

The PARAM element takes four main attributes:

  1. name - this gives the name of the parameter; only relevant to the object that uses it
  2. value - this gives the value of the parameter; only relevant to the object that uses it
  3. valuetype - this gives the type of the value. Valid values are:
    1. ref; that the value is a URI where runtimes are to be found
    2. object; that the value is the identifier of an OBJECT in the document. The identifier is the value of that <OBJECT>s id.
    3. data; default value meaning that the data will be passed as a string
  4. type - this gives the content type; relevant only when the valuetype is ref. E.g., type="application"

Given:

<OBJECT>
<PARAM>
<OBJECT>
<PARAM>
</OBJECT> </OBJECT>

only the child PARAM is used.

Using declared OBJECTs

Declared OBJECTs may be run by use of an A element:

<OBJECT id="useme" declare data="video.mpeg">
</OBJECT>
<A href="#useme">Click to show video</A>

Or:

<OBJECT id="use" declare data="data.data">
</OBJECT>
<OBJECT classid="java.jar">
<PARAM name="data" valuetype="object" value="#use">
</OBJECT>

Embedding HTML

It is possible to embed web pages within web pages; this is done simply by setting data to a web page. E.g., <OBJECT data="webpage.html"></OBJECT>. However, inline frames offer a better alternative when you wish to change the embedded document - inline frames can have their content changed by HTML.

That's the end of this part of the HTML guide. The next section considers frames, so I suggest you click here to continue.