使用图像映射单击鼠标时的警报框

Alert box on mouse click using image mapping

本文关键字:鼠标 图像 映射 单击      更新时间:2023-09-26

如何在鼠标单击图像坐标时生成信息文本或警告框?

以下是我尝试的映射代码行:

<area shape="rect" coords="523,137,658,160" href="#" onclick='alert("Pt.#xxxxx - $xxx.xx")' title="Pt.#xxxxx">

试试这个代码

http://jsfiddle.net/rainerpl/157wq0zq/

click on planets or the sun ( sample from w3schools )<br>
<img src="http://www.w3schools.com/tags/planets.gif" width="145" height="126" alt="Planets"
usemap="#planetmap">
<map name="planetmap">
  <area shape="rect" coords="0,0,82,126" href="javascript: alert('the sun')" alt="Sun" >
  <area shape="circle" coords="90,58,3" href="javascript: alert('the mercury')" alt="Mercury">
  <area shape="circle" coords="124,58,8" href="javascript: alert('the venus')" alt="Venus">
</map>