|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
FORMs Not Supported? It is now very rare, but there are still a few browsers in use that do not support forms. The little checkbox enclosed in square brackets near the top of Figures 2.26 and 2.27 is designed explicitly to handle this situationnote that this button does not do anything, as it lies inside its own FORM and does not have an associated submit button. However, this checkbox does test a browsers support for forms. If the checkbox is absent, then the browser does not support forms, so the reader can see that there is a problem and select the textonly interface. Lessons from Example 10
Exercises for Example 10Constructing FORMs is a complicated compromise of structure and easeofuse: You need to organize the input elements so that they are easy to use and understand, while keeping the form small enough that it does not get confusing. As an exercise, you can try creating HTML versions of some of the formstyle interfaces of standard programs. You will find that TABLEs are one of the most useful tools for constructing well laid out input forms. Chapter 6 gives more details about how FORMs work. At this point, do not worry about the serverside processing of the data other than to give all the form input items appropriate NAMEs. Additional details about forms are found in Chapter 6 and 7, while formbased data processing is discussed in Chapters 10 and 11. Example 11: Inline Data ViewersEMBED and OBJECT ElementsIn Example 5, we looked at hypertext links to data other than other HTML documents and discussed how these data could be processed by external helper applications. Sometimes, however, you do not want exotic data types to be displayed away from the document, but rather want them displayed within the text. For example, you might want an audio or movie player to appear right within the page of a text document or perhaps an Excel spreadsheet to be displayed next to a description of the data. This is possible using the EMBED element (nonstandardized, but supported by Netscape and most other browser vendors) and the newer OBJECT element (partially supported in Internet Explorer 3, more fully but still incompletely supported in Navigator 4 and Internet Explorer 4). These are designed for embedding objects of arbitrary data types within an HTML document, much in the same way that images are embedded using the IMG element. For example, using EMBED, an author can include one of these nonstandard data types using a tag such as which embeds the file movie.avi (a Microsoft AVIformat movie) in the document. How does the browser determine the data type of this file? The type is determined in the same manner described in Example 4: Either the HTTP server explicitly sends a MIME contenttype header to indicate the type, or the browser guesses the type based on the filename extension, using its preconfigured database of filenames and MIME types. <EMBED SRC=/dir/video/movie1.avi WIDTH=200 HEIGHT=150> This only works if the browser knows the filename extensionin fact, there are hundreds of extensions for which the browser has no default MIME type. Therefore, it is always best to serve data out using an HTTP server, since a properly configured Web server always sends the proper contenttype MIME header. For example, the following EMBED element would insert a Corel CMXformat image into a document: <EMBED SRC=cmx/canary.cmx WIDTH=500 HEIGHT=200> Current browsers do not know, by default, what this filename extension (.cmx) means and count on the server to provide the proper contenttype information. The EMBED element can take the three attributes SRC, WIDTH, and HEIGHT, which have the same meanings as with the IMG element. SRC gives the URL for accessing the data, while the HEIGHT and WIDTH give the size for the box that will display the data within the page. In addition, EMBED can take arbitrary userdefined attributes of the form PARAM_NAME=value, where both PARAM_NAME and value are arbitrary, and depend only on the particular data type being displayed. This turns out to be a bad way of doing things and, as a result, the EMBED tag will soon be dropped in favor of the much more flexible OBJECT element. OBJECT is discussed in detail in Chapter 7. Figure 2.28 shows a typical HTML document that uses EMBED to include a special data typein this case, a Corel CMX image. Figures 2.29 and 2.30 show the display of this document by the Netscape Navigator browser. Displaying Embedded DataBrowser PluginsOf course, just getting data to the browser is not sufficient, as you also need a way of displaying it. The problem is that the browser does not know how to do this without help. As you may recall from Example 5, this is the same problem we encountered when linking to arbitrary data typesin this case, the problem was solved by helper applications that processed the data in place of the browser. For embedded data types, we again need the help of additional software, but in this case this help must be plugged right into the browser. Such software modules are thus called browser plugins. Figure 2.29 shows the Netscape Navigator rendering of the page shown in Figure 2.28, where the browser is not equipped with the special plugin capable of displaying Corel CMX image files. The browser, unable to display this data type, substitutes a default symbol indicating this failure. Note also the popup menu that informs the user that the pluggedin data is of an unknown type (the type would be listed as image/xcmx, if the server understood this data type). Figure 2.30 shows the same document, but after the browser has been equipped with the Corel CMX pluginthe browser can now, via the plugin, display the image. In addition, the region displaying the CMX image supports special rightmouse button menu controls for processing and displaying the image. These controls are provided by the plugin module. The bottom of Figure 2.29 and 2.30 show an additional plugin, in this case one that plays audio files. This plugin is a control panel: The slider on the bottom is a volume control, while the other buttons stop, pause, and play the audio file. More sophisticated controls are, of course, found in other plugins. Finally, Figure 2.31 shows what users see when using a browser that does not support plugins. In this case they see nothing, which can lead to very confusing and/or misleading documents. The EMBED element does not allow for an alternative to the embedded data, which is a major weaknesses of the EMBED approach. Figure 2.28 Example HTML document embed.html, which uses the EMBED element to include arbitrary data types within the HTML document. The rendering of this document by the Netscape Navigator browser is shown in Figures 2.29 and 2.30. <HTML><HEAD> <TITLE> Example of the EMBED Element</TITLE></HEAD> <BODY> <H1>Example of the EMBED Element</H1> <BLOCKQUOTE> <P>These simple examples illustrate the <B>EMBED</B> element, as currently implemented on the Netscape Navigator and some other browsers. <BR> <EMBED SRC=canary.cmx WIDTH=200 HEIGHT=150><BR> <P> Here is another <B>EMBED</B>, this time for an audio file. The associated plugin is an audio control panel <EMBED SRC=sound.au WIDTH=145 HEIGHT=60 HSPACE=10 VSPACE=5> the panel is treated like an image. <P> You can also left and rightalign the plugin, in the same way as images. <EMBED SRC=sound.au WIDTH=145 HEIGHT=60 HSPACE=10 VSPACE=5 ALIGN=LEFT> <EMBED SRC=sound.au WIDTH=145 HEIGHT=60 HSPACE=10 VSPACE=5 ALIGN=RIGHT> Here are two examples: note how the text wraps around the panels, just as it wraps around regular image files. </BLOCKQUOTE> </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. |