CIW Course Revision Site

JavaScript - Client-Side JavaScript

In a Nutshell - CIW Course Section 2, Part A2, Chapter 5

Image Maps

While image maps are not a function of JavaScript, it is worth a quick reminder before moving on to the inclusion of JavaScripts with these objects.

An image map is comprised of one or more sets of coordinates relating to a graphical image to define hot-spots or links within the image. Section1, Part B, Chapter 4 contains an image with a hot-spot defined, using HTML only, if you would like to it in action, or would like to review the code.

Adding Scripts to Image Maps

The hot-spot in an image map is functionally the same as a hyperlink, and has the same JavaScript event handlers: onClick, onMouseOver and onMouseOut.

Any or all of these events can be used to trigger the execution of a script. The image below uses the onClick event to display an arbitrary message.

Image Map Target

A point worth mentioning, is the the use of the return value. If you examine the line in the source:

<area href="blimp.php" onClick="return myClick();" shape="circle" coords="40, 29, 9">

you should notice that href points to a page named blimp.html, which in reality does not exist. But, by using the return value in the onClick event with myClick() returning a false value, the link function is not activated, so the non-existent blimp is never looked for.

Design by Stephen

Certified Internet Webmaster

Page last Edited: 10 Nov 2011