interface HTMLCollection
{
readonly attribute unsigned long length;
Node item(in unsigned long index);
Node namedItem(in DOMString name);
}
原文: namedItem method This method retrieves a Node using a name. With [HTML 4.01] documents, it first searches for a Node with a matching id attribute. If it doesn't find one, it then searches for a Node with a matching name attribute, but only on those elements that are allowed a name attribute. With [XHTML 1.0] documents, this method only searches for Nodes with a matching id attribute. This method is case insensitive in HTML documents and case sensitive in XHTML documents. 翻譯: namedItem 方法: 此方法獲通過 "name"屬性來獲取節點. 在HTML4.01文檔中,它首先搜索的是節點的ID屬性的值. 如果沒找到匹配節點,才去搜索name 屬性與之匹配的節點. 即HTML4.01 DTD下,瀏覽器們應該優先通過ID來獲取節點.其次才是name. 在XHTML 1.0文檔中,則僅搜索ID與之匹配的節點. 對于節點(id or name)屬性的值,此方法在HTML文檔中忽略大小寫區別,而在XHTML文檔中.則要區別大小寫. |
微軟MSDN上查到的 NodeList實現 ,雖然這些資料告訴我們 NodeList繼承了 Microsoft.SpeechServer.Dom.Collections.Collection Class . 但是事實卻并不如此. 事實上,ie瀏覽器的NodeList不具備 ICollection接口定義的 namedItem 和 tags 兩個方法. 實現了他們的 只有HTMLCollection類型. 此文檔是 Speech Server 2007 用的,所以應該僅供參考.只能說明IE瀏覽器中的NodeList 還是遵守標準的. public sealed class NodeList : Collection, INodeList, IEnumerable, IExpando, IReflectNodeList的繼承鏈:System.Object Microsoft.SpeechServer.Dom.Shim Microsoft.SpeechServer.Dom.DynamicShim Microsoft.SpeechServer.Dom.Collections.Collection Microsoft.SpeechServer.Dom.Collections.NodeList Collection 實現的ICollection接口定義的屬性和方法表 public properties : item(msdn上說item是重載,我表示詫異...),length public methods : item,namedItem,tags |
The NodeList object returned by the querySelectorAll() method must be static, not live ([DOM-LEVEL-3-CORE], section 1.1.1)
Members Table
The following table lists the members exposed by the StaticNodeList object.
Attributes/PropertiesMethods
Method Description item Retrieves an object from a childNodes or StaticNodeList collection.
Remarks
The collection will be empty if the querySelectorAll method returned no matches.
If the element tree is changed relative to the one or more original selectors used to generate the StaticNodeList collection, the collection (being static) will not be updated when the element tree changes.
限定方 | 方法/瀏覽器 | IE8 | IE9 beta7930.16406 | FireFox4.0 beta7 | Chrome10.0 Dev | Safari5.02 | Opear11 |
| W3C DOM2 | getElementsByTagName | HTMLCollection | HTMLCollection | HTMLCollection | NodeList | NodeList | NodeList |
WHATWG HTML5 | getElementsByClassName | HTMLCollection | HTMLCollection | HTMLCollection | NodeList | NodeList | NodeList |
W3C DOM1 | getElementsByName | HTMLCollection | HTMLCollection | HTMLCollection | NodeList | NodeList | NodeList |
W3c Selectors API 1 | querySelectorAll | StaticNodeList | StaticNodeList | NodeList(Static)(注0) | NodeList(Static) | NodeList(Static) | NodeList(Static) |
W3C DOM1 | childNodes | NodeList | NodeList | NodeList | NodeList | NodeList | NodeList |
MS | children | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
| w3c DOM1 | document.links | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
w3c DOM1 | document.images | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
w3c DOM1 | document.anchors | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
w3c DOM1 | document.forms | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
| w3c DOM1 | document.applets | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
| w3c DOM1 | formElement.elements | HTMLFormElement | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
| w3c DOM1 | selectElement.options | HTMLSelectElement | HTMLSelectElement | HTMLOptionsCollection | HTMLOptionsCollection | HTMLOptionsCollection | HTMLOptionsCollection |
| w3c DOM1 | tableElement.rows | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
| w3c DOM1 | rowElement.cells | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection | HTMLCollection |
| MS | document.all | HTMLCollection | HTMLCollection | (S)-(注4) (Q)object HTML document.all class | HTMLAllCollection(注1) | HTMLAllCollection(注2) | HTMLCollection(注3) |
注4:Freifox在非標準模式,才支持document.all 且是一個很奇怪的東西.其構造器是Object. 這東西從FireFox 0.8時代貌似就有了.一直到現在的4.0 beta8 ...
新聞熱點
疑難解答