DOM 我们了解它了吗?

摘要:
我们遇到过很多ajax应用程序,但您了解DOM技术吗?查看以下信息:官方网站http://www.w3.org/DOM/http://www.w3.org/DOM/Activity实际的DOM推荐是一个API,它定义了XML文档中出现的对象,以及用于访问和处理这些对象的方法和属性。【该文件不符合描述您的记录的网络标准

ajax应用我们遇到的很多,但对于其中的DOM技术,是否了解了呢?看如下的资料:

官网 http://www.w3.org/DOM/http://www.w3.org/DOM/Activity

实际的 DOM 推荐标准是一个 API,它定义了 XML 文档中出现的对象,以及用于访问和处理这些对象的方法和属性。 【The DOM is a set of web standards that describes how your script can interact with and access the structured document. DOM defines the objects, methods, and properties that are required to access, manipulate, and create the content, structure, style, and behavior in your documents.】

DOM是W3C(万维网联盟)标准。

DOM定义了一个标准用来访问像HTML和XML文档。

W3C文档对象模型(DOM)是一个平台和语言无关的接口,允许程序和脚本动态访问和更新文档的内容,结构和样式。

DOM 被分为3中不同的部分/级别:

Core DOM-定义了一套标准的针对任何结构化文档的对象

XML DOM-定义了一套标准的针对 XML 文档的对象

HTML DOM-定义了一套标准的针对 HTML 文档的对象

DOM定义了所有的文档元素的对象和属性,以及访问它们的方法(接口)

从 DOM Level 1 开始,DOM API 包含了一些接口,用于表示可从 XML 文档中找到的所有不同类型的信息。它还包含使用这些对象所必需的方法和属性。

Level 1 包括对 XML 1.0 和 HTML 的支持,每个 HTML 元素被表示为一个接口。它包括用于添加、编辑、移动和读取节点中包含的信息的方法,等等。然而,它没有包括对 XML 名称空间(XML Namespace)的支持,XML 名称空间提供分割文档中的信息的能力。

DOM Level 2 添加了名称空间支持。Level 2 扩展了 Level 1,允许开发人员检测和使用可能适用于某个节点的名称空间信息。Level 2 还增加了几个新的模块,以支持级联样式表、事件和增强的树操作。

DOM Level 3 包括对创建 Document 对象的更好支持、增强的名称空间支持,以及用来处理文档加载和保存、验证以及 XPath 的新模块;XPath 是在 XSL 转换(XSL Transformation)以及其他 XML 技术中用来选择节点的手段。

DHTML

“Dynamic HTML is a term used by some vendors to describe the combination of HTML, style sheets, and scripts that allows documents to be animated” (http://www.w3.org/DOM/#why).

The ideas behind DOM do incorporate DHTML concepts, but DHTML includes nonstandard

objects, such as document.all, that vary from browser to browser. Yes, that’s right;  document.all as well as many other collections are not actually part of W3C standards or recommendations.

DOM Level 0

DOM 最初被当作 Web 浏览器识别和处理页面元素的方式 ―― 即在 W3C 介入之前的功能,称为 “DOM Level 0”。 【There is no DOM Level 0, so don’t go looking for Level 0 specifications. If someone is referring to “Level 0,” they’re most likely referring to a set of proprietary DHTML methods, objects, and collec-tions. These were implemented in different ways across the various browsers before there was a stan-dard specification.】

DOM Level 1

The Level 1 DOM ( http://www.w3.org/DOM/DOMTR#dom1) is the first version of the DOM standard pub-lished as a recommendation way back in October of 1998. It’s a single specification comprised of two main parts:

Ø DOM Core : Gives you the inner workings of the generic tree node structure for XML documents along with the properties and methods required to create, edit, and manipulate the tree.

Ø DOM HTML: Gives you the objects, properties, and methods for the specific elements associ-ated with HTML documents, collections of tags, and each of the individual HTML tags

The Level 1 specification includes object definitions such as Document, Node, Attr, Element, Text, HTMLDocument, HTMLElement, and  HTMLCollection.

DOM Level 2

The Level 2 DOM ( http://www.w3.org/DOM/DOMTR#dom2), published in November of 2000, updates the Core (DOM2 Core) and adds several other specifications. The DOM2 HTML specification was pub-lished in January of 2003 and added additional objects, properties, and methods specific to HTML 4.01 and XHTML 1.0. The DOM 2 recommendations are split into six different specifications:

Ø DOM2 Core: Like DOM Core, this gives you control of the structure of the DOM document but adds additional features, such as namespace-specific methods that you can see in the changes Appendix at http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/changes.html.

Ø DOM2 HTML: Like DOM HTML, this gives you control of HTML-specific DOM documents but includes a few additional properties as noted in the changes Appendix at  http://www.w3.org/TR/2003/REC-DOM-Level-2-HTML-20030109/changes.html.

Ø DOM2 Events : This gives you control of mouse-related events including targeting, capturing, bubbling, and canceling but doesn’t contain handles for keyboard-related events.

Ø DOM2 Style: Alternatively known as DOM2 CSS, this gives you the ability to access and manip-ulate all your CSS-related styling and rules.

Ø DOM2 Traversal and Range : These give you iterative access to the DOM, so you can walk and manipulate the document as needed.

Ø DOM2 Views: This gives you the ability to access and update a representation of a document.

DOM Level 3

http://www.w3.org/2004/03/dom-level-3-pr.html.en

http://www.w3.org/DOM/DOMTR#dom3

Ø DOM3 Core: Adds more new methods and properties to the Core as well as changing a few existing methods as outlined in the changes Appendix at  http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/changes.html

Ø DOM3 Load and Save: Gives you the ability to load the content of an XML document into your DOM document and serialize your DOM document into an XML document

Ø DOM3 Validation: Allows you to ensure your dynamic document is valid and conforms to the doctype

Ø DOM3 Events : Will give access to keyboard- and mouse-related events

Ø DOM3 XPath: Will give access to the DOM document’s tree structure using XPath 1.0 queries (http://www.w3.org/TR/xpath)

Ø DOM3 Views and Formatting and DOM3 Abstract Schemas: Will allow you to  dynamically access and update the content, structure, and style of documents

DOM Level 4

草案中

DOM HTML

HTML DOM 定义了访问和操作HTML文档的标准方法。

The DOM2 HTML specification is rather lengthy, as it contains a specific object for every HTML element. 

Remember that the original DOM2 Core objects still apply, as each of the DOM2 HTML objects

extends from the Core object.

DOM 2 Core API接口选

interface Document : Node {

  readonly attribute DocumentType     doctype;

  readonly attribute DOMImplementation  implementation;

  readonly attribute Element          documentElement;

  Element            createElement(in DOMString tagName)

                                        raises(DOMException);

  DocumentFragment   createDocumentFragment();

  Text               createTextNode(in DOMString data);

  Comment            createComment(in DOMString data);

  CDATASection       createCDATASection(in DOMString data)

                                        raises(DOMException);

  ProcessingInstruction createProcessingInstruction(in DOMString target,

                                                    in DOMString data)

                                        raises(DOMException);

  Attr               createAttribute(in DOMString name)

                                        raises(DOMException);

  EntityReference    createEntityReference(in DOMString name)

                                        raises(DOMException);

  NodeList           getElementsByTagName(in DOMString tagname);

  // Introduced in DOM Level 2:

  Node               importNode(in Node importedNode,

                                in boolean deep)

                                        raises(DOMException);

  // Introduced in DOM Level 2:

  Element            createElementNS(in DOMString namespaceURI,

                                     in DOMString qualifiedName)

                                        raises(DOMException);

  // Introduced in DOM Level 2:

  Attr               createAttributeNS(in DOMString namespaceURI,

                                       in DOMString qualifiedName)

                                        raises(DOMException);

  // Introduced in DOM Level 2:

  NodeList           getElementsByTagNameNS(in DOMString namespaceURI,

                                            in DOMString localName);

  // Introduced in DOM Level 2:

  Element            getElementById(in DOMString elementId);

};

如上可见,我们常用的接口都在上面了。

各浏览器的支持情况

http://www.quirksmode.org/dom/w3c_core.html

参考图书 

JavaScript DOM编程艺术(第2版) http://book.360buy.com/10603153.html 

免责声明:文章转载自《DOM 我们了解它了吗?》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇Python读取大文件的"坑“与内存占用检测H5新增的标签总结下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

Android 编译时:m、mm、mmm、mma、mmma的区别

m:编译整个安卓系统 makes from the top of the tree mm:编译当前目录下的模块,当前目录下需要有Android.mk这个makefile文件,否则就往上找最近的Android.mk文件。 builds all of the moudles in the current directory mma:当前目录新增或删除文件后,可...

关于DOM的操作以及性能优化问题-重绘重排

写在前面: 大家都知道DOM的操作很昂贵。  然后贵在什么地方呢? 一、访问DOM元素 二、修改DOM引起的重绘重排 一、访问DOM   像书上的比喻:把DOM和JavaScript(这里指ECMScript)各自想象为一个岛屿,它们之间用收费桥梁连接,ECMAScript每次访问DOM,都要途径这座桥,并交纳“过桥费”,访问DOM的次数越多,费用也就越高...

odoo javascript

本文介绍了odoo javascript框架。从代码行的角度来看,这个框架不是一个大的应用程序,但它是非常通用的,因为它基本上是一个将声明性接口描述转换为活动应用程序的机器,能够与数据库中的每个模型和记录交互。甚至可以使用Web客户端修改Web客户端的接口。 这里有一个有用的html版本的文档:Javascript API 概览 这个Javascrip...

.NET Core容器化开发系列(一)——Docker里面跑个.NET Core

前言     博客园中已经有很多如何在Docker里面运行ASP.NET Core的介绍了。本篇主要介绍一些细节,帮助初学的朋友更加深入地理解如何在Docker中运行ASP.NET Core。 安装Docker     Docker现支持在主流Linux、Windows和macOS上安装,官方的安装文档请参考docker docs。鉴于国内的网络环境,...

asp.net core系列 30 EF管理数据库架构--必备知识 迁移

一.管理数据库架构概述          EF Core 提供两种主要方法来保持 EF Core 模型和数据库架构同步。一是以 EF Core 模型为基准,二是以数据库为基准。            (1)如果希望以 EF Core 模型为准,请使用迁移。 对 EF Core 模型进行更改时,此方法会以增量方式将相应架构更改应用到数据库,以使数据库保持与...

vue3.x 中获取dom元素

vue3.x的语法虽然和vue2 比没法发生什么变化,但是在写法上发生了很大的变化 在vue2中我们可以通过this$refs.['XX'] 获取dom 元素,但是在vue3.x中已经舍弃了refs,下面就是vue3中获取dom 元素 1.为节点添加一个 ref 名称2.创建 ref 响应式常量并且与 DOM 节点名称一致 ,且值为 null3.在 mou...