<html>
<body>
<h3>以下实例演示了如何访问 MAP 元素</h3>
<img src="/demo/planets.gif" width="145" height="126" alt="Planets" usemap="#myMap">
<map id="myMap" name="myMap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="sun.htm">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mercur.htm">
<area shape="circle" coords="124,58,8" alt="Venus" href="venus.htm">
</map>
<p>点击按钮来获取图像地图中 area 元素的数目。</p>
<p id="demo"></p>
<button onclick="myFunction()">点我</button>
<script>
function myFunction()
{
var x = document.getElementById("myMap").areas.length;
document.getElementById("demo").innerHTML = x;
}
</script>
</body>
</html>