Register for EarthWeb's Million Dollar Sweepstakes!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

HTML 4.0 Sourcebook
(Publisher: John Wiley & Sons, Inc.)
Author(s): Ian S. Graham
ISBN: 0471257249
Publication Date: 04/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


OBJECT Embedding of Applets

Of course, OBJECT can embed many things, not just images or simple data files. As an example, external applets can be included using OBJECT, illustrating that this element is a general-purpose successor to APPLET. Consider the APPLET markup example from Figure 2.32. The APPLET element was:

<APPLET 
CODEBASE=“http://www.dgp.toronto.edu/people/JamesStewart/378/notes/”
   CODE=“bst.class” WIDTH=“321” 
   HEIGHT=“151” VSPACE=“10” HSPACE=“10”ALIGN=“right”>
   <PARAM NAME=keys value=“50 42 43 15 6 23 17 30”>
   <PARAM NAME=action value=“rotate”>
   <PARAM NAME=alternate_nodes value=“15 42”>
   <BLOCKQUOTE>
   <HR> If you were using a Java-enabled Web browser, you would
   see a binary search tree instead of this paragraph. <HR>
   </BLOCKQUOTE>

</APPLET>

where CODEBASE referred to the location of the class libraries, and CODE was the name of the class to run. The following illustrates the same applet embedding, but using OBJECT—the changes are shown in boldface.

<OBJECT
CODEBASE=“http://www.dgp.toronto.edu/people/JamesStewart/378/notes/”
   CLASSID=“java:bst.class” WIDTH=“321”
   HEIGHT=“151” VSPACE=“10” HSPACE=“10” ALIGN=“right”>
   <PARAM NAME=keys value=“50 42 43 15 6 23 17 30”>
   <PARAM NAME=action value=“rotate”>
   <PARAM NAME=alternate_nodes value=“15 42”>
   <BLOCKQUOTE>
   <HR> If you were using a Java-enabled Web browser, you would
   see a binary search tree instead of this paragraph. <HR>
   </BLOCKQUOTE>

</OBJECT>

With OBJECT, CLASSID specifies the class ID for the applet to be run—here, this is a special class-related URL specifying a generic class ID for the desired code. In this case, the actual location of the code is given by the CODEBASE attribute, which is assigned the URL for the library or other resource containing the CLASSID-specified class. If CODEBASE is not given, then the code base takes, as its default value, the URL used to retrieve the document containing the OBJECT. Note, however, that the browser may not need to access the CODEBASE resources—the CLASSID may contain sufficient information that the browser can find the required code on the local filesystem, without accessing it remotely. This is not true for the java URL example given above, but is true in other cases—an example is given below.

CLASSID can also be a URL pointing to the program or class file, in which case CODEBASE may not be necessary, since the object is probably located in the same directory as the required, associated class files. When this is not the case,


Figure 7.23 Client–side imagemaps using OBJECT and MAP elements.

<OBJECT DATA=“activeimage.gif” USEMAP=“#mapref” ALIGN=“left”
          HEIGHT=“200” WIDTH=“180”> >
... alternative markup ...
</OBJECT>
..... additional markup ....
<MAP NAME=“mapref”>
   <AREA HREF=“intro.html” SHAPE=“rect” COORDS=“20,20,60,40”
         ALT=“Introduction”>
   <AREA HREF=“welcome.html” SHAPE=“circle” COORDS=“70,70,10”
         ALT=“Welcome”>
   <AREA HREF=“blobby.html” SHAPE=“poly”
         COORDS=“100,100, 100,110, 110, 120, 90, 130”
         ALT=“Visit Mr. Blobby!”>
   <AREA HREF=“help.html” SHAPE=“default”
         ALT=“help”>
</MAP>

CLASSID often must specify, via special URL scheme names, the type of the code. The names and meanings for some of these special schemes are given in Table 7.3.

OBJECT also can take the optional CODETYPE attribute, which gives the MIME type of the program code. A browser can use this information to skip loading the referenced applet, should the browser not support the indicated type of code. For example, TYPE=“application/com” could indicate a Microsoft COM object—browsers unable to run COM objects could then skip loading the object and instead display the HTML content of the OBJECT.

OBJECT Reference to Active–X Objects

Microsoft first implemented OBJECT to support Active–X embedding—that is, to use OBJECT to embed a variety of Active–X plugins and downloadable code libraries into HTML documents. Active–X objects have CLASSID values of the form:


Table 7.3 Some Special CLASSID URLs

URL Prefix Type of Code Example
java: Java class java:myprogs.bst.bst.class
javabean: A JavaBean class javabean:netscape.open.flyby
clsid: A Microsoft Active–X object clsid:D27CDB6E–AE6D–11CF–96B8–444553540000

clsid:class–identifier

where class–identifier is a global identifier that unambiguously identifies the object. In this case, CODEBASE indicates the location from which the object (and any required supporting code) can be obtained. However, if the Active–X object with the indicated class ID is installed on the browser, the Active–X handler is smart enough to check to see if the local version is up–to–date and use the local version if it is current.

Here is an example OBJECT reference to an Active–X object (some of the URLs have been shortened to reduce the lengths of the lines):

<OBJECT ID=“pilot”
      CLASSID=“clsid:D27CDB6E–AE6D–11CF–96B8–444553540000”
      CODEBASE=“<http://..../flash/cabs/swflash.cab#version=2,1,0,7>”
      ALIGN=“top” BORDER=“0” WIDTH=“90%” HEIGHT=“100%”>

   <PARAM NAME=“Movie” value=“whatson/whatson_new.spl”>
   <PARAM NAME=“Play” value=“true”>
   <PARAM NAME=“loop” value=“false”>
   <PARAM NAME=“Quality” value=“best”>
   <PARAM NAME=“bgcolor” VALUE=“#000000”>

   <EMBED SRC=“whatson/whatson_new.spl” BGCOLOR=“#000000” BORDER=“0”
         TYPE=“application/x–shockwave–flash”
         PLUGINSPAGE=“<http://../index.cgi?P1_Prod_Version=ShockwaveFlash>”
         ALIGN=“left” WIDTH=“90%”  HEIGHT=“100%”
         NAME=“pilot” VALIGN=“top” QUALITY=“best”
         PLAY=“true”  LOOP=“false”>

</OBJECT>

This reference is to a Macromedia Shockwave Splash player, accessible from the indicated CODEBASE. Note how the PARAM element with NAME=“Movie” references the movie file to be played. This URL is passed to the Shockwave player, which retrieves the data and displays it on the page.

Note also how the OBJECT contains an EMBED element, so that older browsers that do not understand OBJECT can fall back to this earlier embedding format.

Referencing Both Data and Data Handler

Finally, an object can reference both the code to be executed and the data to be processed by the code. For example, the following OBJECT element specifies both a data file and a special Java applet that should process the data:

<OBJECT  DATA=“<http://www.whoopee.com/test/frogs.cpt>”
         TYPE=“application/hdf”
         CLASSID=“java:dataanal.hdf.start”
         CODBASE=“<http://hdf.ncsa.uiuc.edu/java–apps/>
”
         CODETYPE=“application/java–vm”>
  <PARAM NAME=“resolution” VALUE=“fine”>
  <P>Sorry, but the browesr was unable to load the Java applet that
  processes the referenced HDF data file. If you have local software
  to analyze HDF data files, please select
  <A HREF=“ <http://www.whoopee.com/test/frogs.cpt”>here</A>
  to directly download the data.</P>
</OBJECT>


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.