您的位置:首页 > Web前端 > Node.js

DOM Node的基本属性在各个浏览器下的区别

2012-02-17 16:54 197 查看
上次开发时发现setUserData在火狐中用不了,详情请看http://blog.csdn.net/luo_yifan/article/details/6851774#comments,现在找到答案了

 

DOM Node节点对象是整个DOM中最主要的数据类型。

节点对象代表了节点树中的一个单独的节点。

这里说的节点可以是:元素节点、属性节点、文本节点以及所有在“Node types[节点类型]”这章中所提到的所有类型的节点。

注意:尽管所有的对象都继承了用以处理子类节点或父类节点的节点属性或节点对象,但是并不是所有的对象有包含子类或是父类。举个例子来说,文本节点中可能不包含子类,所以将子类节点添加到文本节点中可能会导致一个DOM错误。

IE: Internet Explorer, F: Firefox[火狐],
O:
Opera, W3C: World Wide Web Consortium (Internet Standard) | 万维网联盟(国际标准)

Node Object Properties

节点对象属性

属性描述IEFOW3C
baseURIReturns the absolute base URI of a node

返回一个节点的绝对基准URL
No1NoYes
childNodesReturns a NodeList of child nodes for a node

返回一个节点的子节点的节点列表
519Yes
firstChildReturns the first child of a node

返回一个节点的第一个子节点
519Yes
lastChildReturns the last child of a node

返回一个节点的最后一个子节点
519Yes
localNameReturns the local part of the name of a node

返回一个节点的本地名称
No19Yes
namespaceURIReturns the namespace URI of a node

返回一个节点的命名空间的URI
No19Yes
nextSiblingReturns the node immediately following a node

直接返回下一个节点
519Yes
nodeNameReturns the name of a node, depending on its type

返回指定节点类型的节点名称
519Yes
nodeTypeReturns the type of a node

返回节点类型
519Yes
nodeValueSets or returns the value of a node, depending on its type

设置或返回指定节点类型的节点值
519Yes
ownerDocumentReturns the root element (document object) for a node

返回节点的根元素(文档对象)
519Yes
parentNodeReturns the parent node of a node

返回一个节点的父节点
519Yes
prefixSets or returns the namespace prefix of a node

设置或返回一个节点的命名空间前缀
No19Yes
previousSiblingReturns the node immediately before a node

直接返回前面一个节点
519Yes
textContentSets or returns the textual content of a node and its descendants

设置或返回当前节点及其子节点的文本内容
No1NoYes
textReturns the text of a node and its descendants. IE-only property

返回当前节点及其子节点的文本。仅IE支持
5NoNoNo
xmlReturns the XML of a node and its descendants. IE-only property

返回当前节点及其子节点的XML。仅IE支持
5NoNoNo

Node Object Methods

节点对象方法

方法描述IEFOW3C
appendChild()Adds a new child node to the end of the list of children of a node

将一个新的子节点添加到的一个节点中的子类节点列表末尾
519Yes
cloneNode()Clones a node

克隆一个节点
519Yes
compareDocumentPosition()Compares the document position of two nodes

比较两个节点的文档位置
No1NoYes
getFeature(feature,version)Returns a DOM object which implements the specialized APIs of the specified feature and version

返回用于执行包含指定特征和版本的特定APIs的DOM对象
  NoYes
getUserData(key)Returns the object associated to a key on a this node. The object must first have been set to this node by calling setUserData with the same key

返回与当前节点的键相关的对象
  NoYes
hasAttributes()Returns true if a node has any attributes, otherwise it returns false

如过节点包含所有属性,则返回true;反之,则返回false
519Yes
hasChildNodes()Returns true if a node has any child nodes, otherwise it returns false

如果一个节点中包含子节点,则返回true;反之,则返回false
519Yes
insertBefore()Inserts a new child node before an existing child node

在当前子节点之前插入一个新的子节点
519Yes
isDefaultNamespace(URI)Returns whether the specified namespaceURI is the default

返回是否默认当前指定的namespaceURI[命名空间URI]
  NoYes
isEqualNode()Checks if two nodes are equal

检验如果两个节点相等
NoNoNoYes
isSameNode()Checks if two nodes are the same node

检验两个节点是否相同
No1NoYes
isSupported(feature,version)Returns whether a specified feature is supported on a node

返回某个节点是否支持指定的特征
  9Yes
lookupNamespaceURI()Returns the namespace URI matching a specified prefix

返回与一个与指定的前缀相匹配的命名空间的URI
No1NoYes
lookupPrefix()Returns the prefix matching a specified namespace URI

返回与一个与指定的命名空间的URI相匹配的前缀

No1NoYes
normalize()Puts all text nodes underneath a node (including attributes) into a "normal" form where only structure (e.g., elements, comments, processing instructions, CDATA sections, and entity references) separates Text nodes, i.e., there are neither
adjacent Text nodes nor empty Text nodes

其作用是规范化节点。它将一个节点(包括属性)下的所有文本节点按照规范化结构分隔文本节点(如:元素、注释、处理结构、CDATA、片断区域以及实体参数)的标准格式进行处理。这样操作后,节点中既不会出现相邻节点也不会出现空节点。
519Yes
removeChild()Removes a child node

删除一个子节点
519Yes
replaceChild()Replaces a child node

替换一个子节点
519Yes
setUserData(key,data,handler)Associates an object to a key on a node

将一个对象赋到一个节点中的一个键中
  NoYes
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息