javascript常用方法、屬性集合及NodeList 和 HTMLCollection 的瀏覽器差異
interface HTMLCollection
{
readonly attribute unsigned long length;
Node item(in unsigned long index);
Node namedItem(in DOMString name);
}
對于 HTMLCollection集合對象 必須要說一說的是 namedItem方法. 看看規(guī)范的解釋.
原文:
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"屬性來獲取節(jié)點.
在HTML4.01文檔中,它首先搜索的是節(jié)點的ID屬性的值. 如果沒找到匹配節(jié)點,才去搜索name 屬性與之匹配的節(jié)點. 即HTML4.01 DTD下,瀏覽器們應(yīng)該優(yōu)先通過ID來獲取節(jié)點.其次才是name.
在XHTML 1.0文檔中,則僅搜索ID與之匹配的節(jié)點.
對于節(jié)點(id or name)屬性的值,此方法在HTML文檔中忽略大小寫區(qū)別,而在XHTML文檔中.則要區(qū)別大小寫. |
interface NodeList {
Node item(in unsigned long index);
readonly attribute unsigned long length;
};
微軟MSDN上查到的 NodeList實現(xiàn) ,雖然這些資料告訴我們 NodeList繼承了 Microsoft.SpeechServer.Dom.Collections.Collection Class . 但是事實卻并不如此. 事實上,ie瀏覽器的NodeList不具備 ICollection接口定義的 namedItem 和 tags 兩個方法. 實現(xiàn)了他們的 只有HTMLCollection類型.
此文檔是 Speech Server 2007 用的,所以應(yīng)該僅供參考.只能說明IE瀏覽器中的NodeList 還是遵守標準的.
public sealed class NodeList : Collection, INodeList, IEnumerable, IExpando, IReflect
NodeList的繼承鏈:
System.Object
Microsoft.SpeechServer.Dom.Shim Microsoft.SpeechServer.Dom.DynamicShim Microsoft.SpeechServer.Dom.Collections.Collection Microsoft.SpeechServer.Dom.Collections.NodeList Collection 實現(xiàn)的ICollection接口定義的屬性和方法表
public properties : item(msdn上說item是重載,我表示詫異...),length
public methods : item,namedItem,tags |
Element querySelector(in DOMString selectors);
NodeList querySelectorAll(in DOMString selectors);
}
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 且是一個很奇怪的東西.其構(gòu)造器是Object. 這東西從FireFox 0.8時代貌似就有了.一直到現(xiàn)在的4.0 beta8 ...
- node.js使用 http-proxy 創(chuàng)建代理服務(wù)器操作示例
- node.js使用http模塊創(chuàng)建服務(wù)器和客戶端完整示例
- Node.js中使用Log.io在瀏覽器中實時監(jiān)控日志(等同tail -f命令)
- nodejs讀取圖片返回給瀏覽器顯示
- node.js利用redis數(shù)據(jù)庫緩存數(shù)據(jù)的方法
- Nodejs基于LRU算法實現(xiàn)的緩存處理操作示例
- Nodejs下DNS緩存問題淺析
- nodejs使用redis作為緩存介質(zhì)實現(xiàn)的封裝緩存類示例
- Node.js 實現(xiàn)簡單的無侵入式緩存框架的方法
- node Buffer緩存區(qū)常見操作示例
- node.js實現(xiàn)http服務(wù)器與瀏覽器之間的內(nèi)容緩存操作示例
相關(guān)文章
js獲取json中key所對應(yīng)的value值的簡單方法
下面小編就為大家?guī)硪黄猨s獲取json中key所對應(yīng)的value值的簡單方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03JS實現(xiàn)問卷星自動填問卷腳本并在兩秒自動提交功能
這篇文章主要介紹了JS實現(xiàn)問卷星自動填問卷腳本兩秒自動提交功能,本文通過實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2017-08-08javascript實現(xiàn)的樣式表(CSS) 格式整理與壓縮
javascript實現(xiàn)的樣式表(CSS) 格式整理與壓縮,可以分為多行與單行,非常不錯。2010-05-05XHTML-Strict 內(nèi)允許出現(xiàn)的標簽
XHTML-Strict 內(nèi)允許出現(xiàn)的標簽...2006-12-12