views:

141

answers:

1

I need to simulate a mouse click using IE on a client side image map. Which object should invoke the fireEvent()? It cannot be simply the <area> object since it could be referenced by 2 different <img>s. It cannot be the <img> since we need a way to tell which part of the img is clicked which is defined in the <area> tag?

I've done some test with real mouse click on an client side image map. The event object generated from my click indicates (by the event.srcElement property) the event is generated from <area> tag. But when I tried to programmatically call the <area>'s fireEvent(), nothing happened!

A: 

This may be what you're looking for:

<img name="Area" src="Area.jpg" width="240" height="160" border="0" id="Area" usemap="#m_Area" alt="" /><map name="m_Area" id="m_Area">
<area shape="rect" id="A" coords="126,0,240,160" href="javascript:;" onclick="alert('a')" alt="" />
<area shape="rect" id="B" coords="0,0,126,160" href="javascript:;" onclick="alert('b')" alt="" />
</map>
<a href="javascript:document.getElementById('A').onclick()">Test</a>
Diodeus