|
|
The Enumerator object provides the iterating mechanism you can
find in other OOP languages. It supports four methods: atEnd() , item() , moveFirst() , and moveNext() . The following example shows four links to our
four latest tips. These links, together with other links hidden in this tip, form a
collection, document.links . We loop through the items in the collection with
a for() loop. During each iteration we just pop an alert
box with the link's URL. The four methods that the Enumerator object supports are exactly what we need for this
for() loop:
This is the script that implements this loop:
Here are the links and the button you need to click to invoke this script (the first four links are from somewhere else in this tip): 0010108 0010107 0010106 0010105
|
Send mail to santhosh_emids@yahoo.com with questions or comments about
this web site.
|