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 Instead of EMBED

As mentioned earlier, OBJECT is the more fully functional successor to EMBED. As an example of how it works, consider an OBJECT–based equivalent to the EMBED element used in Figure 2.28 to play audio files. First the EMBED:

<EMBED  SRC=“sound.au” WIDTH=“145” HEIGHT=“60” 
                       HSPACE=“10” VSPACE=“5” ALIGN=“LEFT”>

and second, the equivalent OBJECT:

<OBJECT DATA=“sound.au” TYPE=“audio/aiff” WIDTH=“145” HEIGHT=“60” 
                               HSPACE=“10” VSPACE=“5”  ALIGN=“LEFT”>
   <P>The audio says:
   <BLOCKQUOTE> The best, and most enjoyable, way to see ....
   </BLOCKQUOTE>
</OBJECT>

These are quite similar, although the OBJECT element has two obvious advantages. First, the element itself can indicate the MIME type of the resource being referenced (via the TYPE attribute). Second, the content of OBJECT is alternative markup that is displayed when the browser cannot display the specified data, or when it does not understand OBJECT.

Of course there is much more to OBJECT; and refer to Chapter 7 for details.

Microsoft Plugins—ActiveX Controls

Needless to say, Microsoft has also pursued embedded object technology and defined the ActiveX technology as the tool for developing plugins for Microsoft’s Internet Explorer. Software written according to the Microsoft ActiveX specifications will work as a plugin to Microsoft’s Internet Explorer—but unfortunately will not work within Netscape Navigator or Communicator. However, plugins written for Netscape Navigator 3 (but not Navigator 4) will work with Microsoft’s Internet Explorer 3 and 4.

Information about plugins for the Netscape Navigator and Microsoft Internet Explorer browsers can be found, respectively, at:

home.netscape.com/comprod/products/navigator/version_2.0/plugins/index.html
www.microsoft.com/activex/

Plugins: Strengths and Weaknesses

Embedded data richly expands the types of information that can be presented by a Web browser. However, you must keep in mind that not everyone can display the data—most people will not have the required plugin, will be using a computer (e.g., Macintosh or UNIX as opposed to Windows–based) for which there is no appropriate plugin, or will simply be using a browser that does not support plugins. In addition, many plugins require advanced operating systems (Windows 95/NT, Macintosh System 7.5, etc.), fast processors (Pentium or faster), and lots of memory (16 MB or more). If the user’s machine has too little memory or too slow a processor, the plugins will be at best slow and unresponsive.

If you decide to incorporate EMBED/OBJECT elements, you should provide instructions to the readers explaining how to obtain the required plugin. You might also want to provide an alternative to the embedded data should you want to service clients who simply cannot obtain the required software.

For now, plugins are most useful in a semi–controlled environment (such as a corporate intranet), where you can ensure that users will have the required hardware and software.

Lessons from Example 11

1.  Arbitrary data types can be included inline in an HTML document using EMBED or OBJECT elements. EMBED works like the IMG element and takes the same SRC, HEIGHT, and WIDTH attributes, as well as arbitrary attributes specific to the plugin. EMBED is not supported by all browsers and is not part of “standard” HTML.
2.  HTML is currently standardizing around the OBJECT element as a replacement for EMBED. OBJECT, which is more flexible than EMBED, is described in detail in Chapter 6. OBJECT is supported by Netscape Navigator 4 and Internet Explorer 4.
3.  Embedded data types can only be displayed if the browser is equipped with the appropriate plugin. A plugin is a platform– and browser–specific software component that plugs into the browser, giving it the ability to display the associated data type. Most plugins are developed by software vendors responsible for the corresponding data type. Many plugins are available for only a limited number of browsers and/or platforms.

Exercises for Example 11

Examine your inventory of data (audio or video, spreadsheets, special image formats, etc.) and think about how these may or may not be incorporated into HTML documents. Then locate and install the plugin required for a particular data type you would like to use. Next, write some simple Web pages that embed this data type. If you know your intended audience, try polling them (by email, for example) to find out if they have a browser that supports a plugin for this data type. This helps you determine whether this will be an effective way to distribute your resources.

Example 12: Embedded Programs and Applets

In addition to embedding arbitrary data into an HTML document, HTML also supports the embedding of actual programs. Embedded programs are downloaded from a Web server and then run on your local computer. This exciting concept brings with it a host of security concerns: A user has no idea what the program is going to do when it arrives; and after it arrives, it is too late, since the program could have destroyed files, copied passwords to another computer, or done other despicable things.

This has led to the development of several so–called safe languages, the most well–known of which is Java. Java is designed to be both safe (such that running a downloaded Java program cannot damage your computer or access your computer’s files and send them elsewhere) and platform independent. A compiled Java program can thus run on any computer—Windows, UNIX, or Macintosh, regardless of the processor or operating system. Almost all browser vendors now include support for Java programs within their Web browsers. HTML authors can then use the APPLET or OBJECT element to embed Java programs into their pages—the browser downloads the referenced Java program and executes it, using a built–in browser subsystem that supports Java. For security, a downloaded Java program can only run a small, restricted set of functions on the user’s computer.


Figure 2.32 Example HTML document applet.html, which uses the APPLET element to include a Java–language program within an HTML document. The rendering of this document by the Microsoft Internet Explorer 3 browser is shown in Figure 2.33.

<HTML><HEAD><TITLE>Example of an Embedded Applet</TITLE>
</HEAD><BODY>

<H1>Example of an Embedded Applet</H1>
<BLOCKQUOTE>
<P>To the right is a simple example of an embedded
<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>
applet, in this case a Java applet that demonstrates <EM>binary search tree (BST)
rotations</EM>. This is a  complicated concept in computer science, associated
with data storage and searching algorithms. The interactive applet (the user 
can click on the balls to “select and rotate” the data) helps illustrate the
principles in an easy to use and effective manner.
<P>Note how the HTML <EM>content</EM> of the <B>APPLET</B>  element is not 
displayed: the content is alternative markup,  that is displayed by browsers
that do not understand  the <B>APPLET</B> element or that are unable to run 
Java applets.
<P>This applet example is courtesy of James Stewart, an Assistant professor 
in the Department of Computer Science, University of Toronto.
</BLOCKQUOTE>
<HR NOSHADE></BODY></HTML>


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.