home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam    

Book HomeHTML & XHTML: The Definitive GuideSearch this book

6.6. Creating Searchable Documents

Another extensible form of an HTML link that does not use the <a> tag is one that causes the server to search a database for a document that contains a user-specified keyword or words. An HTML document that contains such a link is known as a searchable document.

6.6.1. The <isindex> Tag (Deprecated)

No longer supported in the HTML 4 or XHTML standards, authors at one time used the <isindex> tag to pass keywords along with a search-engine's URL to the server. The server then matched the keywords against a database of terms to select the next document for display. Today's authors mostly use forms to pass information to the server and supporting programs. See Chapter 9, "Forms" for details.



Indicates that a document can be searched










End tag:

None in HTML; </isindex> or <isindex ... /> with XHTML



Used in:


When a browser encounters the <isindex> tag, it adds a standard search interface to the document (rendered by Internet Explorer in Figure 6-8):

<title>Kumquat Advice Database</title>
<base href="cgi-bin/quat-query">
<h3>Kumquat Advice Database</h3>
Search this database to learn more about kumquats!

The user types a list of space-separated keywords into the field provided. When the user presses the Enter key, the browser automatically appends the query list to the end of a URL and passes the information to the server for further processing.

While the HTML and XHTML standards only allow the deprecated <isindex> tag to be placed in the document header, most browsers let the tag appear anywhere in the document and insert the search field in the content flow where the <isindex> tag appears. This convenient extension lets you add instructions and other useful elements before presenting the user with the actual search field.

Figure 6-8

Figure 6-8. A searchable document The prompt attribute

The browser provides a leading prompt just above or to the left of the user-entry field. Internet Explorer's default prompt, for example, is "You can search this index. Type the keyword(s) you want to search for:" (Figure 6-8). That default prompt is not the best for all occasions, so it is possible to change it with the prompt attribute.

When added to the <isindex> tag, the value of the prompt attribute is the string of text that precedes the keyword entry field placed in the document by the browser.

For example, compare Figure 6-8 with Figure 6-9, in which we added the following prompt to the previous source example:

<isindex prompt="To learn more about kumquats, enter a keyword:">
Figure 6-9

Figure 6-9. The prompt attribute creates custom prompts in searchable documents

Older browsers will ignore the prompt attribute, but there is little reason not to include a better prompt string for your more up-to-date readership. The query URL

Besides the <isindex> tag in the header of a searchable document, the other important element of this special tag is the query URL. By default, it is the URL of the source document itself -- not good if your document can't handle the query. Rather, most authors use the <base> attribute to point to a different URL for the search. Section 6.7.1, "The <base> Header Element"

The browser appends a question mark to the query URL, followed by the specified search parameters. Nonprintable characters are appropriately encoded; multiple parameters are separated by a plus sign (+).

In the previous example, if a user types "insect control" in the search field, the browser would retrieve the URL:


Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.