📄 document.html
字号:
<!-- ============ METHOD DETAIL ========== --><A NAME="method_detail"><!-- --></A><TABLE BORDER="1" CELLPADDING="3" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor"><TD COLSPAN=1><FONT SIZE="+2"><B>Method Detail</B></FONT></TD></TR></TABLE><A NAME="getDoctype()"><!-- --></A><H3>getDoctype</H3><PRE>public <A HREF="../../../org/w3c/dom/DocumentType.html">DocumentType</A> <B>getDoctype</B>()</PRE><DL><DD>The Document Type Declaration (see <code>DocumentType</code>) associated with this document. For HTML documents as well as XML documents without a document type declaration this returns <code>null</code>. The DOM Level 2 does not support editing the Document Type Declaration. <code>docType</code> cannot be altered in any way, including through the use of methods inherited from the <code>Node</code> interface, such as <code>insertNode</code> or <code>removeNode</code>.<DD><DL></DL></DD></DL><HR><A NAME="getImplementation()"><!-- --></A><H3>getImplementation</H3><PRE>public <A HREF="../../../org/w3c/dom/DOMImplementation.html">DOMImplementation</A> <B>getImplementation</B>()</PRE><DL><DD>The <code>DOMImplementation</code> object that handles this document. A DOM application may use objects from multiple implementations.<DD><DL></DL></DD></DL><HR><A NAME="getDocumentElement()"><!-- --></A><H3>getDocumentElement</H3><PRE>public <A HREF="../../../org/w3c/dom/Element.html">Element</A> <B>getDocumentElement</B>()</PRE><DL><DD>This is a convenience attribute that allows direct access to the child node that is the root element of the document. For HTML documents, this is the element with the tagName "HTML".<DD><DL></DL></DD></DL><HR><A NAME="createElement(java.lang.String)"><!-- --></A><H3>createElement</H3><PRE>public <A HREF="../../../org/w3c/dom/Element.html">Element</A> <B>createElement</B>(java.lang.String tagName) throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE><DL><DD>Creates an element of the type specified. Note that the instance returned implements the <code>Element</code> interface, so attributes can be specified directly on the returned object. <br>In addition, if there are known attributes with default values, <code>Attr</code> nodes representing them are automatically created and attached to the element. <br>To create an element with a qualified name and namespace URI, use the <code>createElementNS</code> method.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>tagName</CODE> - The name of the element type to instantiate. For XML, this is case-sensitive. For HTML, the <code>tagName</code> parameter may be provided in any case, but it must be mapped to the canonical uppercase form by the DOM implementation.<DT><B>Returns:</B><DD>A new <code>Element</code> object with the <code>nodeName</code> attribute set to <code>tagName</code>, and <code>localName</code>, <code>prefix</code>, and <code>namespaceURI</code> set to <code>null</code>.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</DL></DD></DL><HR><A NAME="createDocumentFragment()"><!-- --></A><H3>createDocumentFragment</H3><PRE>public <A HREF="../../../org/w3c/dom/DocumentFragment.html">DocumentFragment</A> <B>createDocumentFragment</B>()</PRE><DL><DD>Creates an empty <code>DocumentFragment</code> object.<DD><DL></DL></DD><DD><DL><DT><B>Returns:</B><DD>A new <code>DocumentFragment</code>.</DL></DD></DL><HR><A NAME="createTextNode(java.lang.String)"><!-- --></A><H3>createTextNode</H3><PRE>public <A HREF="../../../org/w3c/dom/Text.html">Text</A> <B>createTextNode</B>(java.lang.String data)</PRE><DL><DD>Creates a <code>Text</code> node given the specified string.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - The data for the node.<DT><B>Returns:</B><DD>The new <code>Text</code> object.</DL></DD></DL><HR><A NAME="createComment(java.lang.String)"><!-- --></A><H3>createComment</H3><PRE>public <A HREF="../../../org/w3c/dom/Comment.html">Comment</A> <B>createComment</B>(java.lang.String data)</PRE><DL><DD>Creates a <code>Comment</code> node given the specified string.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - The data for the node.<DT><B>Returns:</B><DD>The new <code>Comment</code> object.</DL></DD></DL><HR><A NAME="createCDATASection(java.lang.String)"><!-- --></A><H3>createCDATASection</H3><PRE>public <A HREF="../../../org/w3c/dom/CDATASection.html">CDATASection</A> <B>createCDATASection</B>(java.lang.String data) throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE><DL><DD>Creates a <code>CDATASection</code> node whose value is the specified string.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>data</CODE> - The data for the <code>CDATASection</code> contents.<DT><B>Returns:</B><DD>The new <code>CDATASection</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</DL></DD></DL><HR><A NAME="createProcessingInstruction(java.lang.String, java.lang.String)"><!-- --></A><H3>createProcessingInstruction</H3><PRE>public <A HREF="../../../org/w3c/dom/ProcessingInstruction.html">ProcessingInstruction</A> <B>createProcessingInstruction</B>(java.lang.String target, java.lang.String data) throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE><DL><DD>Creates a <code>ProcessingInstruction</code> node given the specified name and data strings.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>target</CODE> - The target part of the processing instruction.<DD><CODE>data</CODE> - The data for the node.<DT><B>Returns:</B><DD>The new <code>ProcessingInstruction</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - INVALID_CHARACTER_ERR: Raised if the specified target contains an illegal character. <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</DL></DD></DL><HR><A NAME="createAttribute(java.lang.String)"><!-- --></A><H3>createAttribute</H3><PRE>public <A HREF="../../../org/w3c/dom/Attr.html">Attr</A> <B>createAttribute</B>(java.lang.String name) throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE><DL><DD>Creates an <code>Attr</code> of the given name. Note that the <code>Attr</code> instance can then be set on an <code>Element</code> using the <code>setAttributeNode</code> method. <br>To create an attribute with a qualified name and namespace URI, use the <code>createAttributeNS</code> method.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the attribute.<DT><B>Returns:</B><DD>A new <code>Attr</code> object with the <code>nodeName</code> attribute set to <code>name</code>, and <code>localName</code>, <code>prefix</code>, and <code>namespaceURI</code> set to <code>null</code>. The value of the attribute is the empty string.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character.</DL></DD></DL><HR><A NAME="createEntityReference(java.lang.String)"><!-- --></A><H3>createEntityReference</H3><PRE>public <A HREF="../../../org/w3c/dom/EntityReference.html">EntityReference</A> <B>createEntityReference</B>(java.lang.String name) throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE><DL><DD>Creates an <code>EntityReference</code> object. In addition, if the referenced entity is known, the child list of the <code>EntityReference</code> node is made the same as that of the corresponding <code>Entity</code> node.If any descendant of the <code>Entity</code> node has an unbound namespace prefix, the corresponding descendant of the created <code>EntityReference</code> node is also unbound; (its <code>namespaceURI</code> is <code>null</code>). The DOM Level 2 does not support any mechanism to resolve namespace prefixes.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>name</CODE> - The name of the entity to reference.<DT><B>Returns:</B><DD>The new <code>EntityReference</code> object.<DT><B>Throws:</B><DD><CODE><A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></CODE> - INVALID_CHARACTER_ERR: Raised if the specified name contains an illegal character. <br>NOT_SUPPORTED_ERR: Raised if this document is an HTML document.</DL></DD></DL><HR><A NAME="getElementsByTagName(java.lang.String)"><!-- --></A><H3>getElementsByTagName</H3><PRE>public <A HREF="../../../org/w3c/dom/NodeList.html">NodeList</A> <B>getElementsByTagName</B>(java.lang.String tagname)</PRE><DL><DD>Returns a <code>NodeList</code> of all the <code>Elements</code> with a given tag name in the order in which they are encountered in a preorder traversal of the <code>Document</code> tree.<DD><DL></DL></DD><DD><DL><DT><B>Parameters:</B><DD><CODE>tagname</CODE> - The name of the tag to match on. The special value "*" matches all tags.<DT><B>Returns:</B><DD>A new <code>NodeList</code> object containing all the matched <code>Elements</code>.</DL></DD></DL><HR><A NAME="importNode(org.w3c.dom.Node, boolean)"><!-- --></A><H3>importNode</H3><PRE>public <A HREF="../../../org/w3c/dom/Node.html">Node</A> <B>importNode</B>(<A HREF="../../../org/w3c/dom/Node.html">Node</A> importedNode, boolean deep) throws <A HREF="../../../org/w3c/dom/DOMException.html">DOMException</A></PRE><DL><DD>Imports a node from another document to this document. The returned node has no parent; (<code>parentNode</code> is <code>null</code>). The source node is not altered or removed from the original document; this method creates a new copy of the source node. <br>For all nodes, importing a node creates a node object owned by the importing document, with attribute values identical to the source node's <code>nodeName</code> and <code>nodeType</code>, plus the attributes related to namespaces (<code>prefix</code>, <code>localName</code>, and <code>namespaceURI</code>). As in the <code>cloneNode</code> operation on a <code>Node</code>, the source node is not altered. <br>Additional information is copied as appropriate to the <code>nodeType</code>, attempting to mirror the behavior expected if a fragment of XML or HTML source was copied from one document to another, recognizing that the two documents may have different DTDs in the XML case. The following list describes the specifics for each type of node. <dl> <dt>ATTRIBUTE_NODE</dt> <dd>The <code>ownerElement</code> attribute is set to <code>null</code> and the <code>specified</code> flag is set to <code>true</code> on the generated <code>Attr</code>. The descendants of the source <code>Attr</code> are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Note that the <code>deep</code> parameter has no effect on <code>Attr</code> nodes; they always carry their children with them when imported.</dd> <dt>DOCUMENT_FRAGMENT_NODE</dt> <dd>If the <code>deep</code> option was set to <code>true</code>, the descendants of the source element are recursively imported and the resulting nodes reassembled to form the corresponding subtree. Otherwise, this simply generates an empty <code>DocumentFragment</code>.</dd> <dt>DOCUMENT_NODE</dt> <dd><code>Document</code> nodes cannot be imported.</dd> <dt>DOCUMENT_TYPE_NODE</dt> <dd><code>DocumentType</code> nodes cannot be imported.</dd> <dt>ELEMENT_NODE</dt> <dd>Specified attribute nodes of the source element are imported, and the generated <code>Attr</code> nodes are attached to the generated <code>Element</code>. Default attributes are not copied, though if the document being imported into defines default attributes for this element name, those are assigned.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -