![]() |
|||||
|
|
Client-side ImagemapsClient-side imagemaps use no server processing time and are completely server-independent. There are four steps involved in creating and using a client-side imagemap:
Defining an ImagemapThe map definition is a simple set of HTML tags which describe the x (horizontal) and y (vertical) pixel coordinates of each link in your imagemap. Every tag within the definition describes one link on the image. Map definitions should go at the start of an HTML file, in the head tag.You will use three map tags:
A map of a fishTake a look at this image:
ExerciseThis is a practical exercise that needs is to be carried out in class.Step 1: Create the HTML document The aim of this step is to create a page of HTML containing a map definition for this fish image that allows the user to click on the eye, the fin, and the tail. Step 2: The Fish<html> <head> <title>My Nice Fish</title> <map name="fishmap"> <area shape="rect" coords="1, 35, 45, 118" href="tail.htm"> <area shape="circle" coords="340, 74, 5" href="eye.htm"> <area shape="polygon" coords="190, 43, 152, 19, 113, 46, 126, 52, 190, 43" href="fin.htm"> </map> </head> <body> <img src="fish.gif" width="374" height="164" usemap="#fishmap"> </body> </html> Each line describes a link shape, its coordinates, and the URL associated with it. Use your favourite graphics creation program to find the necessary X,Y coordinates. Notice the word usemap. This tells the browser to use the image as an imagemap and which map definition to use. Remember that you need to use the # symbol. Circles, rects and polygons
rect - this defines a rectangle. The numbers represent the left, top, right and bottom positions of the rectangle. The definition for the rectangle below is:
circle - this defines a circle. The numbers represent the x and y coordinates of the centre of the circle (from the top and the left) followed by the diameter of the circle. The definition for the circle below would be:
polygon - this defines a shape with any number of sides. The numbers represent the x and y coordinates of all the points on the polygon. The definition for the polygon below is:
Notice how point A has its coordinates defined twice, once at the beginning to denote where the shape starts and once at the end to close the shape. ExerciseEnsure to save all files created in this section to the imagemap folder.Step 3: Create the HTML documents that the imagemap will link to. Step 4: Check the imagemap works. Step 5: Identify the coordinates for two new hotspots
Step 6: Add the hotspot information to the HTML file Step 7: Create two new HTML files Step 8: Check the imagemap works.
© 2002 Ashley Preston |
||||
|
|
|||||