Windows Dev Center

item method

Retrieves an object from an areas collection.

Syntax

var retval = areas.item(name, index);

Parameters

name [in]

Type: Variant

Variant of type Integer or String that specifies the object or collection to retrieve. If this parameter is an integer, it is the zero-based index of the object. If this parameter is a string, all objects with matching name or id properties are retrieved, and a collection is returned if more than one match is made.

index [in, optional]

Type: Variant

Variant of type Integer that specifies the zero-based index of the object to retrieve when a collection is returned.

Return value

Type: Object

Returns an object or a collection of objects if successful, or null otherwise.

Standards information

There are no standards that apply here.

Examples

The following example uses the item method to retrieve the alt attribute from each object in the areas collection of a map object.


<body>
<img src ="examples.png" width="200" height="300" 
	alt="Example" usemap ="#example" />
<map id ="example">
  <area shape ="rect" coords ="0,0,100,50" href ="rect.htm" 
    target ="_blank" alt="rectangle" />
  <area shape ="circle" coords ="100,150,10" href ="circle.htm" 
    target ="_blank" alt="circle" />
  <area shape ="poly" coords ="100,300,150,250,200,300" href ="triangle.htm" 
    target ="_blank" alt="triangle" />
</map>
<script type="text/jscript">
  window.onload = function() {
    var oMap = document.getElementsByTagName("MAP")[0];
    var oColl = oMap.areas;
    var sAttr = new Array();
	  
    for (i=0; i<oColl.length; i++) {     
      sAttr[i] = oColl.item(i).getAttribute("alt");                
    }
    console.log("The map has " + oColl.length + " area elements:" + "\n" +
      sAttr[0] + "\n" + sAttr[1] + "\n" + sAttr[2]);  
  }
</script>
</body>

See also

areas

 

 

Show:
© 2015 Microsoft