2015-03-11--A brief analysis of the DOM specification

Source: Internet
Author: User

DOM Level 0
Refers to the browser's proprietary, non-standard methods, objects, and collections.

DOM Level 1 1998 release
Including:
DOM Core
DOM html

DOM Level 2 DOM2 Core 2000 Release DOM2 HTML 2003 release
Including:
DOM2 Core
DOM2 html
DOM2 Events
DOM2 style
DOM2 Traversal and Range traversal
DOM2 views provides the ability to access and update document performance.

DOM Level 3 2007 release
Including:
DOM3 Core
DOM3 Load and save
DOM3 validation
DOM3 Events
DOM3 XPath Example: abc/a
DOM3 views

Use the Domimplementation object to detect if a browser supports a certain DOM-level feature
Domimplementation objects in the browser are instantiated as Document.implementation
Verify that the browser implements a module of a certain level of DOM
Document.implementation.hasFeature (' Module name ', ' Dom level ');
Example: Document.implementation.hasFeature (' Core ', ' 1.0 ');

Dom Core

When the browser parses an HTML file, the markup is converted to an element object based on its own supported DOM module.
Window
Document extension from the Node object
html = documentelement root element
In the DOM specification, whitespace characters between each label are parsed into the text node object. (in IE, whitespace characters are ignored and not parsed as text nodes)

Inherited
The element object inherits all the properties and methods of the Node object.
The inheritance chain is as follows:
Node DOM2 Core Nodename,nodetype,nodevalue,haschildnodes,hasattributes,insertbefore,appendchild ...
|
Element DOM2 Core Tagname,getattribute,setattribute,removeattribute ...
|
HTML Element DOM2 HTML id,title,classname ...
|
Htmlanchorelement (a tag) DOM2 HTML Href,name,rel,accesskey,tabindex,blur,focus ...

Core Node Object
NodeName Element.nodename: The tag name is capitalized; Attr.nodename: attribute name lowercase; Text.nodename: #text;
NodeValue applies only to Text,attr,comments (notes), Cdatasection,processinginstructions objects. Other types of objects return null
NodeType Node.element_node 1,node.attribute_node 2,node.text_node 3; (There is no Node static class object in IE.) )
ParentNode
ChildNodes returns the NodeList object of an array of classes
Example: Document.body.childnodes[0] or Document.body.childNodes.item (0)
FirstChild
LastChild
PreviousSibling
NextSibling
Attributes returns a collection of NamedNodeMap objects for an array of classes, all properties of a node. There are some other convenient methods for NodeList objects, getNamedItem (), such as: Document.body.childnodes[0].getnameditem (' href ');
Example: Document.body.childnodes[0].attributes[0] or Document.body.childNodes.item (0). Attributes.item (0)
Ownerdocument points to the root document that the node belongs to
HasChildNodes
HasAttributes IE does not support
InsertBefore Example: Newnode.insertbefore (Refnode);
appendchild Example: Parentnode.appendchild (NewNode);
removechild Example: Parentnode.removechild (Refnode);
replacechild Example: Parentnode.replacechild (NewNode, Refnode);
CloneNode (True/false) Example: Refnode.clonenode (True)

Core Element Object
GetAttribute (name)
SetAttribute (name, value)
RemoveAttribute (name)
There are also some methods based on DOM attr node objects
GetAttributeNode (name) returns the attr node
Setattributenode (newattr) setting properties based on the new Attr node object
Removeattributenode (oldattr) deletes the specified attribute node
The only way to find the element object in the element object:
getElementsByTagName returns the NodeList object of an array of classes, returning only the element type node, and therefore does not contain the text type node.

Core Document Object
Non-standard: document.all, Document.all[id]
Document.documentelement HTML Tags
Create several common nodes using the Document object
CreateAttribute (name)
Createcomment (data)
CreateElement (TagName)
createTextNode (data)
...
Find an Element object using the Document object
getElementById
getElementsByTagName
The DOM core does not contain getelementsbyclassname because the XML document does not have class properties. This method is defined in the DOM2 HTML


DOM2 HTML

DOM2 HTMLDocument object for HTML
The string in the title title tag
Referrer contains the URL of the previous page connected to the current page
Domain name of the current site in domain
URL of the current page in the Address bar
Body Reference Body Node
Images A collection of all tags in the current document
Applets a collection of all <applet> tags in the current document
Links the collection of all <link> tags in the current document
A collection of all <forms> tags in the forms current document
Anchors a collection of all <a> tags in the current document
A string of all cookie information on the current page of the cookie
Open () opens a document that accepts the write () method output
Close () closes a document
Write (data)
Writeln (data) writes a line break at the same time as the document is written
Getelementsbyname (ElementName)
Some non-standard properties
Frames
Plugins
Scripts
StyleSheets

DOM2 HtmlElement object for HTML
Id
Title
The language code that lang defines for the node language in RFC 1766
ClassName


2015-03-11--A brief analysis of the DOM specification

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.