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


Problems with OBJECT-Based Data References

Figures 7.19 through 7.21 illustrate some of the problems with OBJECT-based data embedding, as currently implemented. Indeed, these problems are so severe that OBJECT-based data embedding should, for the most part, be avoided. The main problems are:

  As demonstrated by the first inclusion example (OBJECT 1), Internet Explorer 4 improperly handles nested OBJECT elements and attempts to render all of the nested OBJECTs, instead of the first supported instance.
  Internet Explorer 4 renders inline data objects with scrollbars. Thus, the HEIGHT and WIDTH values required to fully display the object are not related in an obvious way to the actual size of the embedded object.
  Netscape Navigator 4 does not support OBJECT-based embedding of image or other displayable data content, but does properly render the OBJECT-element content in place of the referenced data.

Additional problems appear when other data are referenced from OBJECT—recall that OBJECT can in principle reference any types of data, not just images or HTML documents. For example, the markup:

<OBJECT DATA=“sound.au” HEIGHT=“60” WIDTH=“160”>
   <P>Audio recording of <A HREF=“sound.au”>Marc Andreesen</A></P>
</OBJECT>

references an audio file. Both Internet Explorer 4 and Netscape Navigator 4 come with plugin modules capable of playing this type of audio file, so that this should work. Indeed, Netscape Navigator understands this markup and displays a control panel for playing the audio file. Internet Explorer 4, however, crashes whenever it tries to load the file—and on occasion, completely crashes the Windows 95 operating system!

Imagemaps and OBJECT-Embedded Images

Since OBJECT elements can embed images, it is important that these images can be imagemapped in the same manner as IMG elements. Indeed, the OBJECT specification supports two mechanisms for imagemapping embedded objects, outlined in the following sections. Note, however, that OBJECT does not support server-side imagemaps, only client-side ones—if you want server-side imagemaps, you must use IMG elements or form INPUT elements of TYPE=“image.”


OBJECT-Based Imagemaps Not Currently Supported

OBJECT-based imagemaps are not supported by Internet Explorer 4 or Netscape Navigator 4, since neither of these browsers properly supports

OBJECT-based embedding of images.


OBJECT Imagemaps (1)—The SHAPES Attribute

The recommended form for adding imagemaps to OBJECT-embedded images makes use of a proposed extension to the anchor element. An example of this is shown in the HTML document listed in Figure 7.22—the attributes associated with the imagemap are shown in boldface.

As with IMG, the ALIGN attribute specifies the desired alignment for the displayed object (the image). The SHAPES attribute tells the browser that this object is an imagemap—as a result, the browser looks, within the HTML markup inside the


Figure 7.18 Document illustrating the use of OBJECT to embed data. Browser renderings of this document are found in Figures 7.19, 7.20, and 7.21.

<HTML>
<HEAD>
<TITLE>Test of OBJECT-based DATA Inclusions</TITLE>
</HEAD><BODY BGCOLOR=“#ffffff”>

<P><B>OBJECT 1 (.gif inside .tiff) </B><BR>
<OBJECT HEIGHT=“25” WIDTH=“100” DATA=“button.tif” TYPE=“image/tiff”>
  <OBJECT HEIGHT=“25” WIDTH=“100” DATA=“button.gif” TYPE=“image/gif”>
    <IMG SRC=“button.gif”>  
  </OBJECT>
</OBJECT>

<P><B>OBJECT 2 (.html)</B><BR>
<OBJECT HEIGHT=“100” WIDTH=“300” DATA=“demo.html” TYPE=“text/html”>
  <IFRAME SRC=“demo.html” HEIGHT=“100” WIDTH=“300”>
    <P>Alternative text for browsers that don't support
       <B>OBJECT</B> inclusion of HTML, or <B>IFRAME</B>.</P>
  </IFRAME>
</OBJECT>
</BODY></HTML>

OBJECT, for anchor elements containing the SHAPE and COORDS attributes—these contain the map coordinate information. If a browser does not support OBJECT, the user then sees the enclosed list of hypertext anchors as regular HTML markup. Thus the approach provides fully functional links or imagemaps, regardless of the browser’s capabilities.


Figure 7.19  Rendering, by Internet Explorer 4, of the document listed in Figure 7.18. Note how, with the first example (OBJECT 1), this browser mistakenly tries to display both nested OBJECTs.


Figure 7.20  Rendering, by Netscape Navigator 4, of the document listed in Figure 7.18. This browser does not understand OBJECT elements that include data in this manner and instead displays the content of the OBJECT.


Figure 7.21  Rendering, by Netscape Navigator 3, of the document listed in Figure 7.18. This browser does not understand OBJECT.

A Elements Inside an OBJECT

As noted, A elements within an OBJECT support two new attributes relating the anchor reference to regions within the OBJECT-referenced image. The attributes and their meanings are:

SHAPE=“circle,” “default,” “poly,” “rect” (optional: only valid inside A within OBJECT) SHAPE is valid only for anchor elements inside OBJECT elements, as discussed previously. SHAPE, in combination with the COORDS attribute, defines active regions of the image referenced by an OBJECT and attaches these regions to the remote resource indicated by the HREF attribute. SHAPE simply specifies the type of shape, the possible values being “circle,” “default,” “poly,” and “rect.”
COORDS=“string” (optional: mandatory if SHAPE is present and if SHAPE is not equal to “default”)Specifies the coordinates associated with the designated SHAPE, measured from the upper left-hand corner of the image. Coordinates can either be integer quantities, in which case they are measurements in pixels from the upper-left hand corner or percentage values in the range (0%,0%) (the upper left-hand corner) to (100%, 100%) (lower right-hand corner).


Figure 7.22 Client-side imagemaps using OBJECT and special A element attributes.

<OBJECT DATA=“activeimage.gif” SHAPES  ALIGN=“left” HEIGHT=“200” WIDTH=“180”>
  <A HREF=“intro.html” SHAPE=“rect”
     COORDS=“20,20,60,40”>Introduction</A> |
  <A HREF=“welcome.html” SHAPE="circle" COORDS="70,70,10">Welcome</A> |
  <A HREF="blobby.html"  SHAPE="poly" 
     COORDS="100,100, 100,110, 110, 120, 90, 130">Visit Mr. Blobby!</A> |
  <A HREF="help.html"    SHAPE="default">Help</A>

</OBJECT>

The following table describes appropriate COORDS values for the different SHAPEs.


SHAPE COORDS
“circle” x, y, r”—A circle centered at (x,y) and of radius r.
“rect” x_top, y_top, x_bot, y_bot”—A rectangle with upper-left hand coordinates (x_top, y_top) and lower right-hand coordinates (x_bot, y_bot).
“poly” x1, y1, ... xn, yn”—A polygon, where the coordinates (x1,y1) .... (xn,yn) are the vertices of the polygon (minimum of three vertices). The polygon is closed by connecting the point (x1,y1) to (xn, yn).

OBJECT Imagemaps (2)—The USEMAP Attribute

For compatibility with the MAP element approach to client-side imagemaps (see Chapter 6), OBJECT also supports a USEMAP attribute, equivalent to the USEMAP attribute of the IMG element. Figure 7.23 shows a USEMAP equivalent to the client-side imagemap first given in Figure 7.22—once again, the attributes associated with the imagemap are highlighted in boldface. Although similar to the approach described in the previous section, this method does not provide a simple HTML text alternative for browsers that do not support 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.