Hi Folks,

Is there a way to define actions for default area not specified in ?

For example if I have an image which has 3 portions mapped, and for the rest portion of the image, I want to have a javascript that alerts the user to click on the predefined areas, is that possible?

I tried:

<img src="img/pic.png" width="512" height="512" usemap="#main_map" border=0 onclick="javascript:alert('Please Click on the Text Items')"/>
<map name="main_map">
<area shape="rect" href="#name section" title= "a" alt="a" coords="0,0,256,256"/>
<area shape="rect" href="#group section" title= "b" alt="b" coords="266,0,512,256"/>
<area shape="rect" href="#hobbies section" title= "c" alt="c" coords="0,266,512,512"/>

It simply alerts for all the area's =/

Could anyone shed a light on this please?

1 answer


Is the use of an image map an absolute must? I believe they're deprecated due to usability/accessibility concerns. For the same reason, it would be nicer to have a fallback for cases where javascript is not available.

There are a few good CSS 'image map' mechanisms available. I believe they will give you much greater control over how the 'image map' is presented, and you can handle hovering over a non-clickable region using CSS too.

Answered about 7 years ago by Bobby Jack