Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q1609 Can you use an imagemap with onClick?

irt.org | Knowledge Base | JavaScript | Image | Q1609 [ previous next ]

Q1609 Can you use an imagemap with onClick?

Yes, as the following shows:

<map name="image-map1">
<area shape="rect" coords="15,15,85,85" href="default.htm"
   onClick="alert('square');return false">
<area shape="rect" coords="93,15,110,85" href="default.htm"
   onClick="alert('rectangle');return false">
<area shape="circle" coords="150,50,35" href="default.htm"
   onClick="alert('circle');return false">
</map>

<img src="image.gif" border=0 width=200 height=100 usemap="#image-map1">

However, there is no need o do this as you can instead use a javascript: schema in the href attribute as follows:

<map name="image-map2">
<area shape="rect" coords="15,15,85,85" href="javascript:alert('square')"
<area shape="rect" coords="93,15,110,85" href="javascript:alert('rectangle')"
<area shape="circle" coords="150,50,35" href="javascript:alert('circle')"
</map>

<img src="image.gif" border=0 width=200 height=100 usemap="#image-map2">

Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.