Note : The Areas collection is Internet Explorer specific. Netscape includes all <AREA>
element objects in the Links collection. For properties, methods and events that are supported by <AREA>
element, see the Client Side Image Maps topic.
The Areas collection is an ordered, indexed array, containing a reference to every <AREA>
element in a given <MAP>
element. A separate Areas collection is available for each different <MAP>
element in the document and the Areas collection can only be referenced through a reference to a valid <MAP>
element object.
Area Objects would normally be retrieved by their index in the Areas collection. I.e.:
document.<MAP>reference.areas(1).href
returns the HREF
attribute of the second <AREA>
element in the <MAP>
element referenced by <MAP>
reference. For example, consider the following:
<MAP NAME="Map1">
<AREA SHAPE="circle" COORDS="52,49,35" HREF="index.htm">
<AREA SHAPE="rect" COORDS="53,34, 131,82" HREF="start.htm">
</MAP>
Calling the following in a script function:
document.all('Map1').areas(1).href
would return start.htm
. (Note that the <MAP>
element doesn't have to be referenced through the All Collection)
A string value can be used however, as long as that string is a valid identifier (ID
attribute value) for an <AREA>
element in the referenced <MAP>
element in the document.
E.g.
document.<MAP>reference.areas('Area1').title
would return the TITLE
attribute of the <AREA>
whose NAME
, or ID
property is 'Area1', in the <MAP>
element referenced by <MAP>
reference.
length
The length
property returns the number of areas in the collection. Note that the length
count starts at 1, not 0 as the areas collection index does. Therefore, the length
property may return a value of 5, but to access the 3rd area in a <MAP>
, you'd need to use document.<MAP>reference.areas(2).property
item
The item
method retrieves single items, or sub-collections from an areas collection. It accepts the following arguments:
areas.item(index, sub-index)
If index
is a number, then the method returns a reference to the <AREA>
at that position in the areas collections index. I.e.
strTag=document.<MAP>reference.areas.item(2).title
would make strTag
be the value of the TITLE
attribute of the <MAP>
's third <AREA>
. As you can see, this is effectively the long-hand version of using document.<MAP>reference.areas(2).property
.
If the index
property is a string value, then the item
method returns a sub-collection, containing a reference to every area in the map that has its NAME
or ID
attribute set to the string contained in the index
argument. To retrieve certain element objects from this sub-collection, the sub-index
argument must be used.
© 1995-1998, Stephen Le Hunte
file: /Techref/language/html/ib/Scripting_Reference/areacol.htm, 4KB, , updated: 2004/3/1 15:47, local time: 2024/11/21 20:34,
3.23.103.216:LOG IN
|
©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions? <A HREF="http://massmind.org/techref/language/html/ib/Scripting_Reference/areacol.htm"> The Areas collection</A> |
Did you find what you needed? |
Welcome to massmind.org! |
Welcome to massmind.org! |
.