Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

image map javascript onclick event not working



3:02 pm on Sep 22, 2011 (gmt 0)

5+ Year Member

hi i have tried a simple onclick event on image map but was not functioning ,i can't able to figure it out.

<script type="text/javascript">
function Get(What)
{ alert(What); }


<map name="Map" id="Map">
<area shape="rect" coords="356,160,364,168" href="#" onclick="Get(6);" alt="this is city area" />


4:28 pm on Sep 22, 2011 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

Map before closing body tag?
Are you sure the coords are correct, and you're correctly referencing the map? The cursor should turn into a pointer when moused over.

<img src="someimage.jpg" usemap="#Map" alt="imagemap">

Remembering that map and Map are not the same thing . . .

Also if you've made this error,

<p id="Map"><img src="someimage.jpg" usemap="#Map" alt="imagemap"></p>

ID's must be unique, rename one or the other. Also when you get it working you might want to make these two changes:

function Get(What)
{ alert(What); return false; }

<map name="Map" id="Map">
<area shape="rect" coords="356,160,364,168" href="#" onclick="return Get(6);" alt="this is city area" />

.. so the page doesn't navigate to the top.


8:19 am on Sep 23, 2011 (gmt 0)

5+ Year Member

i have taken care of things u have mentioned now sometimes get popup and sometime i don't on click of image map,
how to set popup very next to image map .


5:01 am on Sep 25, 2011 (gmt 0)

5+ Year Member

i have manage to get popup next to hot spot now my problem is its showing in IE -7 and above but not in firefox and Chrome

Featured Threads

Hot Threads This Week

Hot Threads This Month