设置网页图片热点链接

在一张图片上设置一个热点,鼠标点击图片的不同区域可以进入不同的页面或者进行一些不同的操作,这就是网页的热点链接。

示例代码如下:

<img src="图片路径" usemap="#map" alt="" />

<map name="map" id="map">

  <area shape="circle" coords="100,100,20" href ="javascript:alert(1)" />

  <area shape="circle" coords="150,150,10" href ="javascript:alert(2)" />

  <area shape="rect" coords="0,0,100,100" href ="javascript:alert(3)" />

</map>

注意:<img> 中的 usemap 属性可引用 <map> 中的 id 或 name 属性(根据浏览器的内核不同来决定),所以我们需要同时向 <map> 添加 id 和 name 两个属性

 

 

 
 
 
 
 





原文地址:https://www.cnblogs.com/caichunbao/p/6343389.html