Register for EarthWeb's Million Dollar Sweepstakes!
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.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next



CAUTION:  

An imagemap definition file should never contain both a point and a default region. If point regions are defined and a user does not click a hot region, the server sends the user to the URL associated with the closest point region and the default URL will never be used.


Following each type of region in the imagemap definition file is the URL that is returned to the user when a click within that area is recorded. Active regions in the definition file are read from the first line down. If two regions overlap in their coordinates, the imagemap program uses the first region it encounters in the file.


CAUTION:  

URLs in map files should always be absolute or fully qualified URLs—that is, the URL should specify a protocol, a server name, and a filename (including the directory path to the file).



NOTE:  You can use the pound sign (#) to comment on a line in the imagemap definition file. Any line beginning with a pound sign is ignored by the imagemap program. Comments are useful for adding information, such as the date of creation, the physical path to the imagemap graphic, or specific comments about the server configuration.

Two primary types of map file configurations exist: one for the original CERN-style imagemaps and one for the NCSA server’s implementation of imagemaps. Both use the same types of hot regions and the same coordinates to define each type. However, the formatting of this information in each map file is different. Therefore, you should check with the system administrator about the particular imagemap setup of the server you are using.


NOTE:  Most major HTTP servers today use the NCSA map format. This includes Netscape Enterprise Server and Windows 98/NT–based servers, such as Microsoft Internet Information Server (IIS) or Microsoft Peer Web Services (PWS).

CERN Map File Format Lines in a CERN-style map file have the following form:

region_type coordinates URL

The coordinates must be in parentheses, and the x and y coordinates must be separated by a comma. The CERN format also doesn’t allow for comments about hot regions. A sample CERN-style hot region definition might look like the following:

circle (123,89) (146,132) <http://www.server.com/circle.html>

NSCA Map File Format NCSA developed a slightly different format from CERN’s for map file information. Their format is as follows:

region_type URL coordinates

The coordinates don’t have to be in parentheses, but they do have to be separated by commas. The equivalent of the map data line presented previously in NCSA format is as follows:

circle <http://www.server/circle.html> 123,89,146,132

Setting Up the Imagemap

Because of the differences in imagemap processing programs on different servers, you can use two techniques for setting up imagemaps.

Pointing Directly at the Processing Scripting The first approach, most commonly used with NCSA and CERN servers, involves a direct call to the imagemap processing program on the server. The HREF attribute is set equal to the URL to the imagemap processing script followed by a slash (/) and the name of the map defined in the server’s imagemap.conf file. In the following example, the name of the map is mainpage. The actual graphic is then included with the <IMG> tag. The <IMG> tag also includes the ISMAP attribute, indicating that the image placed by the tag is to be a server-side imagemap. Using this approach, your imagemap link might look like this:

<A HREF=“/cgi-bin/imagemap/mainpage”>
<IMG SRC=“images/mainpage.gif” ISMAP></A>

For this example to work, the imagemap.conf file must also include a line pointing to a map file for the imagemap mainpage. That line might look like the following:

mainpage : /maps/mainpage.map

Entries in the imagemap.conf file enable the imagemap program to find the map files you create. You need a similar entry in the imagemap.conf file for each imagemap you want the server to process.

Pointing Directly at the Map File Linking to the imagemap script on the server is somewhat easier under Netscape and Microsoft HTTP servers. For this program, you just use the following line with an NCSA-style map file:

<A HREF=“/maps/mainpage.map”>
<IMG SRC=“images/mainpage.gif” ISMAP></A>

These servers don’t require the imagemap.conf file, so you can “eliminate the middleman” and point directly to the map file. When the server detects a call for a map file, it automatically invokes the imagemap processing program.

Example: A Main Page Imagemap

You use the following code to set up the image you saw in Figure 4.1 in a CERN-style map file:

rect (166,255) (368,382) <http://www.server.com/info.html>
circle (160,151) (160,224) <http://www.server.com/index.html>
poly (308,86) (378,109) (421,52) (421,122) (491,149) (420,169) (419,245)
(377,185) (306,205) (349,148) <http://www.server.com/new.html>

For a server that works with the NCSA map file format, you use this:

rect <http://www.server.com/info.html> 166,255 368,382
circle <http://www.server.com/index.html> 160,151 160,224
poly <http://www.server.com/new.html> 308,86 378,109 421,52 421,122
491,149 420,169 419,245 377,185 306,205 349,148

With a map file set up in one style or another, you then set up the imagemap with this code:

<A HREF=“<http://www.server.com/cgi-bin/imagemap/mainpage>”>
<IMG SRC=“images/map2.gif” ISMAP ...></A>

The preceding code is for servers that use an imagemap.conf file or with this:

<A HREF=“<http://www.server.com/maps/mainpage.map>”>
<IMG SRC=“images/map2.gif” ISMAP ...></A>

This code is for servers that automatically go to the map file.


NOTE:  If you are using a server with an imagemap.conf file, you also need a line in that file matching the name “mainpage” with the map file mainpage.map:
mainpage : /maps/mainpage.map

Example: A Navigation Imagemap

The CERN format map file for the image you saw in Figure 4.2 would look like the following:

rect (1,1) (112,36) <http://www.server.com/index.html>
rect (113,1) (224,36) <http://www.server.com/new.html>
rect (225,1) (335,36) <http://www.server.com/info.html>
rect (336,1) (447,36) <http://www.server.com/search/index.html>
rect (448,1) (560,36) <http://www.server.com/contact.html>

If you are preparing a map file in NCSA format, use the following:

rect <http://www.server.com/index.html> 1,1 112,36
rect <http://www.server.com/new.html> 113,1 224,36
rect <http://www.server.com/info.html> 225,1 335,36
rect <http://www.server.com/search/index.html> 336,1 447,36
rect <http://www.server.com/contact.html> 448,1 560,36

After your map file is done in the appropriate format, you set up the imagemap with

<A HREF=“<http://www.server.com/cgi-bin/imagemap/navigate>”>
<IMG SRC=“images/navigation2.gif” ISMAP ...></A>

or with

<A HREF=“<http://www.server.com/maps/navigate.map>”>
<IMG SRC=“images/navigation.gif” ISMAP ...></A>

depending on whether the server uses an imagemap.conf file.


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.