322Part IIIDocument Objects ReferenceThe tags()method does not belong (Web hosting control panel)
322Part IIIDocument Objects ReferenceThe tags()method does not belong to every element, but it is a method of every collectionof objects (such as all, forms, and elements). The method is best thought of as a kind of fil- ter for the elements that belong to the current collection. For example, to get an array of all pelements inside a document, use this expression: document.all.tags( P ) You must pass a parameter string consisting of the tag name you wish to extract from the col- lection. The tag name is case-insensitive. The return value is an array of references to the objects within the current collection whosetags match the parameter. If there are no matches, the returned array has a length of zero. Ifyou need cross-browser compatibility, use the getElementsByTagName()method describedearlier in this chapter, and pass a wildcard value of * . ExampleUse The Evaluator (Chapter 13) to experiment with the tags()method. Enter the followingstatements one at a time into the upper text box and study the results: document.all.tags( div ) document.all.tags( div ).lengthmyTable.all.tags( td ).lengthBecause the tags()method returns an array of objects, you can use one of those returnedvalues as a valid element reference: document.all.tags( form )[1].elements.tags( input ).lengthRelated Item:getElementsByTagName()method. urns( behaviorURN ) Returns:Array of element objects. Compatibility:WinIE5+, MacIE-, NN-, Moz-, Safari- The urns()method does not belong to every element, but it is a method of every collectionof objects. You must pass a parameter string consisting of the URN (Uniform Resource Name) of a behavior resource (most typically .htc) assigned to one or more elements of the collec- tion. The parameter does not include the extension of the filename. If there is no matchingbehavior URN for the specified parameter, the urns()method returns an array of zero length. This method is related to the behaviorUrnsproperty, which contains an array of behaviorURNs assigned to a single element object. ExampleIn case the urns()method is reconnected in the future, you can add a button and function toListing 15-19b that reveals whether the makeHot.htcbehavior is attached to the myPele- ment. Such a function looks like this: function behaviorAttached() { if (document.all.urns( makeHot )) { alert( There is at least one element set to makeHot . ); } } Related Item:behaviorUrnsproperty. elementObjectCollection.tags()