PDA

View Full Version : Capturing onclick event in <map> tag


Rev_Onin
05-15-2003, 06:18 PM
Hi All,

I am trying to capture create an onclick event in the href of a area tag in the map tag. The onclick event will then open a window to display an image. I have the following code. The function to open the window works, I just can't figure out how to capture the click correctly.

<script>
function openPicture(picfront, picBack, picWidth, picHeight)
{
This code works fine
}
</script>


<map name="Map">
<area shape="rect" coords="65,90,173,166" href="javascript: onclick='openPicture('clash-f','null',500,356);'">
</map>

Could anyone please help me with this one.

Many thanks
Andrew

arnyinc
05-15-2003, 06:43 PM
I'm pretty sure image maps work like links, so you just need to specify onclick and href as different attributes and that should fix it. You can put whatever you want as the href, but the # will just link to nothing (it will make the page jump to the top I think).

<area shape="rect" coords="65,90,173,166" href="#" onclick="javascript:openPicture('clash-f','null',500,356);">

Danne
05-15-2003, 08:41 PM
... and don't forget the
usemap="#Map" -property in the img-tag....

<img src="someImage.gif" usemap="#Map">