|
To access the contents, click the chapter and section titles.
HTML 4.0 Sourcebook
where x and y are the integer pixel coordinates of the mouse pointer measured from the upper left-hand corner of the image. Note that the path my_database is included at the end of the URL. As discussed in Chapters 8 and 10, URLs that point to program resources are treated in a special way, and any directory-like information appended to the URL after the program name (like my_database) is treated as extra path information and is passed as a parameter to the gateway program. In this example, my_database is path information used by imagemap to find the imagemap database for this particular image. Thus, imagemap can be used with any number of active images, each image having its own personalized database. Imagemap is an actual CGI program for handling active image data, distributed with the current NCSA and Apache HTTP servers. Since it is CGI-compliant it should, in principle, run on any server. This program comes with all versions of the NCSA and Apache servers. Built-in Server Imagemap Support The Apache, Netscape, NCSA, and most other servers are now equipped with built-in modules that work in exactly the same manner as imagemap. If you have this feature, then you do not need the imagemap program. However, if you do need it, the following section describes how to obtain, create, and install the package. Installing Imagemap If you dont have the program and wish to install it, simply download the files and compile with your C compilernote that the program requires the CGI-utility package utils.c. You then install the imagemap executable in your servers CGI program directory. By default, this is often cgi-bin, located in the directory structure containing the server executable, server support directories, and configuration files. (This is not the directory that contains the HTML and other documents made available via the server.) The program is now accessible through URLs of the form:
<http://some.site.edu/cgi-bin/imagemap> where the cgi-bin directory is a virtual name used by the server to reference the directory containing CGI programs. Check your server configuration files (or with your server administrator) to verify that this name is correct. Creating an Imagemap DatabaseThe imagemap database file relates a region of the image with a URL to be accessed when a user clicks inside that region. You can specify regions as circles, rectangles, polygons, or points. You can also include comments in a map database file by placing a hash character (#) as the first character in the line. Figure 3.3 shows a simple map file, named blobby.map, while Figure 3.4 shows the figure and the areas associated with the mapped regions. This file declares that clicks within the circle centered at coordinates 226,40 (and with an edge at 5116,10) are linked to the designated URL and makes similar declarations for a rectangle (indicated by rect) and a polygon (indicated by poly). These coordinates are measured in pixels from the upper left-hand corner of the image. The default method indicates the URL to access if the user clicks in places not falling inside any of the mapped regions. The general form of a map file entry is method URL x1,y1 x2,y2 ... xn,yn where method specifies the manner in which the region is being specified (one of circle, rect, poly, point, or default), URL is the URL to be accessed if the click occurs inside this region, and xn and yn are the integer coordinates of a point, measured from the upper left-hand corner of the image. The coordinates are measured in pixels, so you will need some way of measuring the pixel coordinates in an image. Tools for doing this are presented later. Note that mapped regions can overlap. The imagemap program reads the map file from the beginning, and if a click occurs at a point lying within two mapped regions, the program takes the first region it encounters. The URLs specified in a map file can be complete URLs, or partial URLs of the form /path/stuff/file which references a file or gateway program relative to the HTTP server document directory. With the NCSA, Apache, and certain other servers, you can also use the form where user is the name of a user on the system. This references a file or gateway program relative to the users personal HTML area. Figure 3.3 The example imagemap map database file blobby.map. The meanings of the different region types (circle, rect, etc.) are discussed in the text. # Imagemap file for blobby.gif circle /dir1/blob2/his_head.html 116,40 116,10 rect /dir1/blob2/his_hand.html 36,30 84,90 poly /dir1/blob2/his_foot.html 86,154 64,170 76,188 104,184 112,166 default /cgi-bin/nph-no_op.sh
|
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. |