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 还是遵守标准的.
<strong><span><span style="COLOR: #a8a8a8">public sealed class NodeList : Collection, INodeList, IEnumerable, IExpando, IReflect</span></span></strong> <span style="COLOR: #a8a8a8"><strong><span><span><strong><span style="COLOR: #a8a8a8">NodeList的继承链:</span></strong></span></span></strong></span>
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을 지원하며 이는 매우 이상한 일입니다. 이 기능은 FireFox 0.8 베타8부터 사용 가능한 것 같습니다. ...