|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
To set up a circular hot region, for example, you would use code such as the following: <MAP NAME=circle> <AREA SHAPE=circle COORDS=123,89,49 HREF=<http://www.server.com/circle.html> ALT=Circle Link> </MAP> The preceding HTML sets up a map named circle that has one hot region. Note that the numbers in the list of coordinates for the COORDS attribute are all separated by commas, and the URL in the HREF attribute is fully qualified. Note also that the coordinates list comprises the coordinates of the center point followed by a single number that represents the radius of the circle. The <AREA> tag can also take a NOHREF attribute, which tells the browser to do nothing if the user clicks the hot region. Any part of the image that is not defined as a hot region is taken to be a NOHREF regionif users click outside a hot region, they dont go anywhere by default. This approach saves you from setting up an <AREA SHAPE=DEFAULT NOHREF> tag for all your maps.
Setting Up the ImagemapAfter the imagemap data is set up in HTML form, you need to set up the imagemap itself. To do this, you use the <IMG> tag along with the USEMAP attribute. USEMAP tells the browser that the image to be used is a client-side imagemap. It is set equal to the name of the map that contains the appropriate map data. For the client-side imagemap defined previously, the setup would look like this: <IMG SRC=images/mainpage.gif USEMAP=#circle> The pound sign (#) before the map name indicates that the map data is found in the same HTML file. If the map data is in another file called maps.html (which is perfectly okay), your <IMG> tag would look like the following: <IMG SRC=images/mainpage.gif USEMAP=<http://www.server.com/maps.html#circle>>
Example: A Main Page ImagemapFigure 4.1 shows an image to be used as an imagemap on the main page of a small corporate site. The coordinates to define the hot regions in the image are given in Table 4.2.
To set up the map information to make the image in Figure 4.1 a client-side imagemap, you could use the following HTML: <MAP NAME=mainpage> <AREA SHAPE=rect COORDS=166,255,368,382 HREF=<http://www.server.com/info.html> ALT=Site Map> <AREA SHAPE=circle COORDS=160,151,73 HREF=<http://www.server.com/index.html> ALT=Search> <AREA SHAPE=polygon COORDS=308,86,378,109,421,52,421,122,491,149,420,169, 419,245,377,185,306,205,349,148" HREF=<http://www.yourserver.com/whatsnew.html> ALT=Whats New> </MAP> Then, to set up the imagemap, you would use the following if the map information were in the same file: <IMG SRC=images/map2.gif USEMAP=#mainpage> If the map information were stored in the file maps.html, you would modify the preceding <IMG> tag to read as follows: <IMG SRC=images/map2.gif USEMAP=<http://www.server.com/maps.html#mainpage>>
|
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. |