Share via


activeElements Collection

This topic documents a feature of HTML+TIME 2.0, which is obsolete as of Windows Internet Explorer 9.

Returns a reference to the collection of all top-level child elements of the object that are currently active on the timeline.

Syntax

[ oColl = ] object.activeElements
[ oObject = ] object.activeElements(iIndex)

Possible Values

oColl Array of elements contained by the object.
oObject Reference to an individual item in the array of elements contained by the object.
iIndex Required. Integer that specifies the zero-based index of the item to be returned.

Members Table

The following table lists the members exposed by the activeElements object.

Property Description
length

Gets the number of objects in a collection.

Method Description
item

Retrieves an object from the specified collection by index.

Remarks

The BODY element behaves like a t:PAR element, or parallel time container. Therefore, you can retrieve all the currently active top-level elements in the document by applying the activeElements collection to the BODY element.

As with other Dynamic HTML (DHTML) collections, you can use an index value to access objects contained in the activeElements collection. However, you might encounter scripting errors, because the contents of this collection can change quickly as local timelines expire in the document. Typically, these errors occur when using an index value that becomes invalid because a timeline ends and the collection contains fewer objects. To prevent these errors, avoid stepping through each object in the collection that uses a for loop that starts at index 0 and then processes each element until it reaches the last index. Instead, use the Enumerator object in Microsoft JScript, or the For Each...Next statement in Microsoft Visual Basic Scripting Edition (VBScript).

Example

The following example shows how to access each member of the activeElements collection.

<HTML>
<HEAD>
<TITLE>activeElements Collection</TITLE>
<STYLE>
    .time {behavior:url(#default#time2);}
</STYLE>
<XML:NAMESPACE PREFIX="t"/>
<SCRIPT LANGUAGE="JScript">
function showActive() { 
    var oAE = new Enumerator(parallel.activeElements);
    var myStr = "";
    for(; !oAE.atEnd(); oAE.moveNext()) {
    myStr = myStr + "\nElement Type: <" + oAE.item().tagName + 
    ">; Element ID: " + oAE.item().id;
    }
    alert("Currently Active Elements: " + myStr);
}
</SCRIPT>
</HEAD>
<BODY ID="docBody">
<P>Click the button below to display the elements that are 
currently active on the timeline. In this sample, active elements 
are displayed in color while they are active. Elements that are
inactive are displayed in black.
</P>
<BUTTON STYLE="width:140px;" onclick="showActive();">Show Active 
Elements</BUTTON>
<t:PAR CLASS="time" ID="parallel" timeaction="none" DUR="9" 
REPEATCOUNT="indefinite">
    <H1 ID="hdg1" CLASS="time" STYLE="color:red;" 
    TIMEACTION="style" BEGIN="0" DUR="3">Heading 1</H1>
    <H2 ID="hdg2" CLASS="time" STYLE="color:red;" 
    TIMEACTION="style" BEGIN="0" DUR="3">Heading 2</H2>
    <H3 ID="hdg3" CLASS="time" STYLE="color:blue;" 
    TIMEACTION="style" BEGIN="3" DUR="3">Heading 3</H3>
    <H4 ID="hdg4" CLASS="time" STYLE="color:blue;" 
    TIMEACTION="style" BEGIN="3" DUR="3">Heading 4</H4>
    <H5 ID="hdg5" CLASS="time" STYLE="color:green;" 
    TIMEACTION="style" BEGIN="6" DUR="3">Heading 5</H5>
    <H6 ID="hdg6" CLASS="time" STYLE="color:green;" 
    TIMEACTION="style" BEGIN="6" DUR="3">Heading 6</H6>
</t:PAR>
</BODY>
</HTML>

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/behaviors/htmltime/activeElements.htm

Applies To

t:EXCL, t:PAR, t:SEQ

See Also

Introduction to HTML+TIME, timeAll, timeChildren