I’ve got an image map with 20 area elements, only four shown below. I want to style each area so that a blue border appears whenever a user hovers over it – all the area shapes are rectangles.
<map id="mymap" name="mymap">
<area shape="rect" coords="0,0,223,221" href="http://..." />
<area shape="rect" coords="226,0,448,221" href="http://..." />
<area shape="rect" coords="451,0,673,223" href="http://..." />
<area shape="rect" coords="677,0,1122,223" href="http://..." />
...
</map>
I’ve tried using CSS to style each area, but it’s not working. And I’ve tried to put an onmouseover=color() on the map element and call the following function, but that doesn’t seem to be working either:
function color() {
var blueboxes = document.getElementsByTagName('area');
for(var i=0; i<blueboxes.length; i++) {
blueboxes[i].style.border = 'solid blue 5px';
}
}
mapper.js can be used for this.
Sample code from that website:
Setting Up
Download mapper.js and include it into your webpage.
"wz_jsgraphics.js" is copyright by Walter Zorn and not part of the distribution!
Using It
To get the highlighting just add a class="mapper" to an div surrounded image.
To get individual area highlightings add one or more classes to the area.
To get multiple area selections add one or more id’s to the areas rel attribute.
To force a group of areas using the attributes of the initial area.