Reputation: 3
I have a large image on an html/php page and I was wondering how I could specify parts of the image to show different tooltips when hovered over.
EDIT: I found this code in another post, how can I make it display tooltips instead of an alert? And how would I specify more than 1 hover area?
<html>
<head>
<script language="JavaScript">
function getDetails(obj){
clickX = window.event.x-obj.offsetLeft;
clickY = window.event.y-obj.offsetTop;
if((clickX>=100&&clickX<=200)&&(clickY>=100&&clickY<=200))
{
alert(" You are between (100,100) And (200,200) of the Image");
}
}
</script>
</head>
<body>
<img src="image.jpg" onMousemove="getDetails(this)" id="myimg" height="500" width="500" />
</body>
</html>
Sorry I'm still learning how this site works. Thanks in advance!
Upvotes: 0
Views: 2369
Reputation: 3755
Use HTML map tag, then define a title for each area.
<img src="planets.gif" width="145" height="126" alt="Planets" usemap="#planetmap">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" href="sun.htm" title="Sun">
<area shape="circle" coords="90,58,3" href="mercur.htm" title="Mercury">
<area shape="circle" coords="124,58,8" href="venus.htm" title="Venus">
</map>
Upvotes: 5