|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
OBJECT Instead of EMBEDAs mentioned earlier, OBJECT is the more fully functional successor to EMBED. As an example of how it works, consider an OBJECTbased 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 PluginsActiveX ControlsNeedless to say, Microsoft has also pursued embedded object technology and defined the ActiveX technology as the tool for developing plugins for Microsofts Internet Explorer. Software written according to the Microsoft ActiveX specifications will work as a plugin to Microsofts Internet Explorerbut unfortunately will not work within Netscape Navigator or Communicator. However, plugins written for Netscape Navigator 3 (but not Navigator 4) will work with Microsofts Internet Explorer 3 and 4. Information about plugins for the Netscape Navigator and Microsoft Internet Explorer browsers can be found, respectively, at:
Plugins: Strengths and WeaknessesEmbedded 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 datamost people will not have the required plugin, will be using a computer (e.g., Macintosh or UNIX as opposed to Windowsbased) 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 users 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 semicontrolled environment (such as a corporate intranet), where you can ensure that users will have the required hardware and software. Lessons from Example 11
Exercises for Example 11Examine 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 AppletsIn 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 socalled safe languages, the most wellknown 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 computers files and send them elsewhere) and platform independent. A compiled Java program can thus run on any computerWindows, 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 pagesthe browser downloads the referenced Java program and executes it, using a builtin browser subsystem that supports Java. For security, a downloaded Java program can only run a small, restricted set of functions on the users computer. Figure 2.32 Example HTML document applet.html, which uses the APPLET element to include a Javalanguage 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 Javaenabled 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>
|
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. |