Click here for ObjectSpace: Business- to- Business Integration Company
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


Table 3.1 gives the specifications of the five methods for declaring active regions in an imagemap database.


Table 3.1 Methods Specifications for Imagemap Databases. The string link_URL is the URL to which the selected region is linked.

circle link_URL xc, yc xe, ye

This maps the region inside the indicated circle to the given URL. Two coordinate pairs are required: one for the circle center (xc,yc) and the other for an edgepoint (xe,ye) lying on the edge of the circle. An example entry is: circle /path/file.html 50,40 20,30
point link_URL x,y

This declares a specific point in an image as active. When you click on the image, and the click is not inside a circle, rectangle, or polygon, the imagemap program locates the point closest to the coordinates of the click and accesses the indicated URL.
poly link_URL x1,y1 x2,y2 . . . xn,yn

This maps the region inside the indicated polygon to the given URL. Each coordinate pair represents a vertex of the polygon. You should make sure that the line segments do not cross one another (no bow ties!). The polygon is automatically closed by linking the last point xn,yn to the first coordinate x1,y1. The current NCSA program limits you to 100 corners in a given polygon.
rect link_URL xul, yul xlr, ylr

This maps the region inside a rectangle to the given URL. The coordinates of the upper left (xul,yul) and lower right (xlr,ylr) corners of the rectangle are required, in that order. An example entry is: rect http://banzai.com/booger.html 20,20 40,50
default link_URL

This URL is accessed if the click did not lie inside any other region. This is never accessed if you define a point, since a clicked location will always be closest to a defined point, even if it’s the only one!

Referencing the Imagemap Database

Now that you have a database—for example the blobby.map database of Figure 3.3—where should you put it, and how does the imagemap program know where to find it? This database can go anywhere you can put regular HTML documents or data files. You indicate its location to the imagemap program via extra path information in the URL. For example, let us suppose that the Web server document directory is /u/Web and that the collection of documents and images related to Mr. Blobby is found in the directory /u/Web/weird/blobby. One choice is to put the map file in the same directory as the image, so that the absolute path for the map file is /u/Web/weird/blobby/blobby.map. You access this map file from imagemap by using the markup

<A HREF=“<http://some.site.edu/cgi-bin/imagemap/weird/blobby/blobby.map>”>
   <IMG SRC=“blobby.gif” ISMAP>
</A>

where some.site.edu is the site containing the documents and the extra path information that references the imagemap database is in boldface. Note that the path to blobby.map, relative to the document directory of the HTTP server (/u/Web), has been added to the imagemap URL (it is shown in boldface). The string “/weird/blobby/blobby.map” is passed to imagemap and is used by the program to locate the database blobby.map.

With most servers, this method is not restricted to the regular document directory. If a user has a personal HTML directory, he or she can place map files in this directory and access the maps using URLs like

<A HREF=“<http://some.site.edu/cgi-bin/imagemap/~user/path/blobby.map>”>
<IMG SRC=“blobby.gif” ISMAP>
</A>

where user is the username of the person with the personal public HTML directory and path/blobby.map is the path leading to the map file from the root of his or her personal document directory.

Getting a Click to Do Nothing

Sometimes, you want a click to do nothing. For example, your image could be a map of buildings, and you don’t want anything to happen if the user clicks on nonmapped objects, like roads or trees. In this case, you might want the browser to keep the current document on the browser window screen. This can be accomplished by linking the default method in your imagemap file to a server CGI program that returns a response message to the client. In Figure 3.3, the default method references the UNIX shell script nph-no_op.sh, designed to do exactly this. This script, along with an equivalent program written in perl, is listed in Figure 3.5.


Figure 3.5 Listing for (A) the Bourne shell script nph-no_op.sh, and (B) the perl script nph-no_op.pl. Both return HTTP headers that tell a browser to continue displaying the currently displayed document.

(A) nph-no_op.sh—Bourne shell script

#!/bin/sh
echo “HTTP/1.0 204 No response -- server CGI-script output”
echo “Content-type: text/plain”
echo “Server: $SERVER_SOFTWARE”
echo

(B) nph-no_op.pl—Perl script

#!/bin/perl
print “HTTP/1.0 204 No Response -- CGI script output \r\n”;
print “Content-type: text/plain\r\n”;
print “Server: $ENV{“SERVER_SOFTWARE}\r\n”;
print “\r\n”;  #Blank line ending the header

Output from scripts having an nph- prefix is sent directly to the client without being parsed by the server (see Chapter 10 for more information on non-parsed header gateway programs). This script sends the HTTP status code 204, which tells the client that there is no server message and that the client should continue displaying the current document.


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.