JavaScript Reference/Javascript Collections/areas

Материал из Web эксперт
Версия от 18:30, 25 мая 2010; (обсуждение)
(разн.) ← Предыдущая | Текущая версия (разн.) | Следующая → (разн.)
Перейти к: навигация, поиск

"areas" Example

    
<html>
<head>
<script language="JavaScript">
function function1() {
    var m = document.all.myMap.areas.length;
    alert("There are "+m+" areas within the map "myMap""); 
}
</script>
</head>
<body onload="function1();">
<p>
<img src="yourImage.gif" 
     alt="" 
     width="200" 
     height="100" 
     usemap="#myMap"> 
<map name="myMap"> 
    <area id="area1" 
          shape="rect" 
          coords="0, 0, 100, 50" 
          href="http://www.wbex.ru" 
          onClick="return false">
    <area id="area2" 
          shape="rect" 
          coords = "100, 0, 200, 50" 
          href="http://www.wbex.ru" 
          onClick="return false">
</map>
</p>
</body>
</html>



"areas" is applied to

+----------------+--------------------------------------------------------------+
| Applied_To     |<map>                                                         |
+----------------+--------------------------------------------------------------+



"areas" JavaScript properties and JavaScript methods

JavaScript properties and JavaScript methods
 
add(), item(), length, namedItem(), remove(), tags(), urns()



"areas" Syntax Parameters and Note

Note:
Returns an array of all <area> elements contained in a <map> element.
    
Syntax:
    
document.getElementById("mapID").areas // returns all areas
document.getElementById("mapID").areas(param1, param2) // returns an individual area
document.all.mapID.areas // IE only 
document.all.mapID.areas(param1, param2) // IE only

    param1    Required; zero-based index or 
                        desired member"s id or name attribute.
    param2    Optional; zero-based index for the result returned
                        if param1 matches more than one element.