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
Node Object Methods
DOM Node节点对象是整个DOM中最主要的数据类型。
节点对象代表了节点树中的一个单独的节点。
这里说的节点可以是:元素节点、属性节点、文本节点以及所有在“Node types[节点类型]”这章中所提到的所有类型的节点。
注意:尽管所有的对象都继承了用以处理子类节点或父类节点的节点属性或节点对象,但是并不是所有的对象有包含子类或是父类。举个例子来说,文本节点中可能不包含子类,所以将子类节点添加到文本节点中可能会导致一个DOM错误。
IE: Internet Explorer, F: Firefox[火狐],
O: Opera, W3C: World Wide Web Consortium (Internet Standard) | 万维网联盟(国际标准)
Node Object Properties
节点对象属性
属性 | 描述 | IE | F | O | W3C |
---|---|---|---|---|---|
baseURI | Returns the absolute base URI of a node 返回一个节点的绝对基准URL | No | 1 | No | Yes |
childNodes | Returns a NodeList of child nodes for a node 返回一个节点的子节点的节点列表 | 5 | 1 | 9 | Yes |
firstChild | Returns the first child of a node 返回一个节点的第一个子节点 | 5 | 1 | 9 | Yes |
lastChild | Returns the last child of a node 返回一个节点的最后一个子节点 | 5 | 1 | 9 | Yes |
localName | Returns the local part of the name of a node 返回一个节点的本地名称 | No | 1 | 9 | Yes |
namespaceURI | Returns the namespace URI of a node 返回一个节点的命名空间的URI | No | 1 | 9 | Yes |
nextSibling | Returns the node immediately following a node 直接返回下一个节点 | 5 | 1 | 9 | Yes |
nodeName | Returns the name of a node, depending on its type 返回指定节点类型的节点名称 | 5 | 1 | 9 | Yes |
nodeType | Returns the type of a node 返回节点类型 | 5 | 1 | 9 | Yes |
nodeValue | Sets or returns the value of a node, depending on its type 设置或返回指定节点类型的节点值 | 5 | 1 | 9 | Yes |
ownerDocument | Returns the root element (document object) for a node 返回节点的根元素(文档对象) | 5 | 1 | 9 | Yes |
parentNode | Returns the parent node of a node 返回一个节点的父节点 | 5 | 1 | 9 | Yes |
prefix | Sets or returns the namespace prefix of a node 设置或返回一个节点的命名空间前缀 | No | 1 | 9 | Yes |
previousSibling | Returns the node immediately before a node 直接返回前面一个节点 | 5 | 1 | 9 | Yes |
textContent | Sets or returns the textual content of a node and its descendants 设置或返回当前节点及其子节点的文本内容 | No | 1 | No | Yes |
text | Returns the text of a node and its descendants. IE-only property 返回当前节点及其子节点的文本。仅IE支持 | 5 | No | No | No |
xml | Returns the XML of a node and its descendants. IE-only property 返回当前节点及其子节点的XML。仅IE支持 | 5 | No | No | No |
Node Object Methods
节点对象方法
方法 | 描述 | IE | F | O | W3C |
---|---|---|---|---|---|
appendChild() | Adds a new child node to the end of the list of children of a node 将一个新的子节点添加到的一个节点中的子类节点列表末尾 | 5 | 1 | 9 | Yes |
cloneNode() | Clones a node 克隆一个节点 | 5 | 1 | 9 | Yes |
compareDocumentPosition() | Compares the document position of two nodes 比较两个节点的文档位置 | No | 1 | No | Yes |
getFeature(feature,version) | Returns a DOM object which implements the specialized APIs of the specified feature and version 返回用于执行包含指定特征和版本的特定APIs的DOM对象 | No | Yes | ||
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 返回与当前节点的键相关的对象 | No | Yes | ||
hasAttributes() | Returns true if a node has any attributes, otherwise it returns false 如过节点包含所有属性,则返回true;反之,则返回false | 5 | 1 | 9 | Yes |
hasChildNodes() | Returns true if a node has any child nodes, otherwise it returns false 如果一个节点中包含子节点,则返回true;反之,则返回false | 5 | 1 | 9 | Yes |
insertBefore() | Inserts a new child node before an existing child node 在当前子节点之前插入一个新的子节点 | 5 | 1 | 9 | Yes |
isDefaultNamespace(URI) | Returns whether the specified namespaceURI is the default 返回是否默认当前指定的namespaceURI[命名空间URI] | No | Yes | ||
isEqualNode() | Checks if two nodes are equal 检验如果两个节点相等 | No | No | No | Yes |
isSameNode() | Checks if two nodes are the same node 检验两个节点是否相同 | No | 1 | No | Yes |
isSupported(feature,version) | Returns whether a specified feature is supported on a node 返回某个节点是否支持指定的特征 | 9 | Yes | ||
lookupNamespaceURI() | Returns the namespace URI matching a specified prefix 返回与一个与指定的前缀相匹配的命名空间的URI | No | 1 | No | Yes |
lookupPrefix() | Returns the prefix matching a specified namespace URI 返回与一个与指定的命名空间的URI相匹配的前缀 | No | 1 | No | Yes |
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、片断区域以及实体参数)的标准格式进行处理。这样操作后,节点中既不会出现相邻节点也不会出现空节点。 | 5 | 1 | 9 | Yes |
removeChild() | Removes a child node 删除一个子节点 | 5 | 1 | 9 | Yes |
replaceChild() | Replaces a child node 替换一个子节点 | 5 | 1 | 9 | Yes |
setUserData(key,data,handler) | Associates an object to a key on a node 将一个对象赋到一个节点中的一个键中 | No | Yes |
相关文章推荐
- 不同浏览器的区别和基本认识
- html5学习canvas基本使用:div在js前面;localStorage存储根据浏览器在不同的位置;应用程序缓存;placeholder 属性提供一种提示(hint),描述输入域所期待的值。
- CSS中visibility属性的collapse属性值有什么用?在不同浏览器下有什么区别?
- computed属性和watch属性的区别之二【computed的基本用法】
- 【JavaScript】基本数据类型与引用数据类型区别(及为什么String、Boolean、Number基本数据类型会有属性和方法?)
- contenteditable属性浏览器支持情况(基本支持)-工作草稿
- contentSize、contentInset和contentOffset 是 scrollView三个基本的属性区别和使用
- 细说HTML元素的ID和Name属性的区别
- JS判断浏览器是否支持某一个CSS3属性的方法
- Java千百问_01基本概念(006)_线程和进程有什么区别
- C# 字段与属性区别
- @Font-face的基本用法及让全部浏览器都兼容的方法
- border、margin、padding属性的区别
- 各种浏览器全屏模式的方法、属性和事件介绍(转)
- Unix原理与应用学习笔记----第六章 文件的基本属性1
- android 中targetSdkVersion和与target属性的区别
- 区别不同浏览器,CSS hack写法
- 各浏览器 for-in 遍历对象属性的顺序差异
- IE “浏览器模式”和“文档模式”的区别
- php 类属性 和python 类属性的 区别