imagemap onMouseOver solution

Serv0 picture Serv0 · Apr 20, 2012 · Viewed 7.3k times · Source

I want to create imagemap with the few areas.

<img src="map.png" alt="map" usemap="#planetmap" />

<map name="planetmap" id="map">
  <area onMouseover="showtext('New York!')" 
        shape="circle" 
        coords="90,58,3" 
        href="#" alt="NY"/>
</map>

I want the text show up when get over the shape (like a hint). Can you tell me where the problem is? I find the solutions with combination of the css / javascript but i prefer the simplest solution.

Thank you.

Juraj

Answer

srini picture srini · Apr 20, 2012

try this

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; 
            charset=iso-8859-1" />
        <title>Map Document</title>
        <script type="text/javascript">
            function showtext(text){
                alert(text);
            }
         </script>
    </head>

    <body>
        <img src="map.png" width="145" height="126" alt="Map" 
             usemap="#planetmap" />

        <map name="planetmap" id="map">
            <area shape="circle" 
                  coords="90,58,3" 
                  alt="Venus" 
                  href="#" 
                  onmouseover="showtext('New York!')" />
        </map>
    </body>
</html>