可怜的浏览器兼容问题,。只有FF有比较规范一点的文档,
http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-summary.html------------DOM
http://www.w3.org/TR/DOM-Level-3-Core/core.html#i-Document Study document
https://developer.mozilla.org/en/JavaScript --------------------------JavaScript 版本
In the DOM, the document object provides a general way to represent HTML, XHTML, and XML documents. Document objects implement the general DOM Core document interface (which itself implements the Node interface).
In addition to the generalized DOM Core document interface, HTML documents also implement the DOM HTMLDocument interface, which is a more specialized interface for dealing with HTML documents (e.g., document.cookie, document.alinkColor). Methods listed here that are part of this more specialized interface have an asterisk (*) next to them.
The document is contained by the window object and may contain any number of elements.
The document interface provides access to things such as the document type, its color and formatting, plugins and applets, as well providing methods for creating and manipulating all of the document's child nodes, or elements, such as BODY and TABLE elements.
Name | Description | Return Type | Availability |
---|---|---|---|
document.activeElement |
Returns the currently focused element | Element | HTML 5 |
document.alinkColor Deprecated |
Returns or sets the color of active links in the document body. | String | DOM 0 |
document.all | |||
document.anchors |
Returns a list of all of the anchors in the document. | HTMLCollection [1] | HTML |
document.applets |
Returns an ordered list of the applets within a document. | HTMLCollection | HTML |
document.async |
async is used with document.load to indicate an asynchronous request. | n/a | DOM 3 |
Node.attributes |
Returns a collection of attributes of the given element | NamedNodeMap | |
Node.baseURI |
baseURI gets the base URI for the document | String | DOM 3 |
document.baseURIObject New in Firefox 3 |
baseURIObject returns an nsIURI object representing the base URI for the document. |
nsIURI |
All |
document.bgColor Deprecated |
Gets/sets the background color of the current document. | String | DOM 0 |
document.body |
Returns the BODY node of the current document. | HTMLBodyElement [2] | HTML |
document.characterSet |
Returns the character set being used by the document. | String | DOM 0 |
Node.childNodes |
returns a collection of child nodes of the given node | NodeList | |
document.compatMode |
Indicates whether the document is rendered in Quirks or Strict mode. | String | HTML, XHTML |
document.contentType |
Returns the Content-Type from the MIME Header of the current document. | String | |
document.cookie |
Returns a semicolon-separated list of the cookies for that document or sets a single cookie. | String | HTML |
document.defaultView |
Returns a reference to the window object. | Window | DOM 2 View |
document.designMode |
Gets/sets WYSYWIG editing capability of Midas. It can only be used for HTML documents. | String | HTML |
document.dir |
Gets/sets directionality (rtl/ltr) of the document | String | |
document.doctype |
Returns the Document Type Definition (DTD) of the current document. | DocumentType [3] | DOM 2 Core |
Name | Description | Return Type | Availability |
document.documentElement |
Returns the Element that is a direct child of document. For HTML documents, this is normally the HTML element. | Element | All |
document.documentURI |
Returns the document location. | String | DOM 3 |
document.documentURIObject New in Firefox 3 |
Returns the nsIURI object representing the URI of the document. This property only has special meaning in privileged JavaScript code (with UniversalXPConnect privileges). |
nsIURI | |
document.domain |
Returns the domain of the current document. | String | HTML |
document.domConfig |
Should return a DOMConfiguration object | DOMConfiguration | DOM 3 |
document.embeds |
Returns a list of the embedded OBJECTS within the current document. | HTMLCollection | DOM 0 |
document.fgColor Deprecated |
Gets/sets the foreground color, or text color, of the current document. | String | DOM 0 |
document.fileSize |
Returns size of the document or <img> element. | Number | IE ext. |
Node.firstChild |
Returns the first node in the list of direct children of the document. | DocumentType | DOM 2 Core |
document.forms |
Returns a list of the FORM elements within the current document. | HTMLCollection | HTML |
document.height |
Gets/sets the height of the current document. | Number | DOM 0 |
document.images |
Returns a list of the images in the current document. | HTMLCollection | HTML |
document.implementation |
Returns the DOM implementation associated with the current document. | DOMImplementation [4] | DOM 2 Core |
document.inputEncoding |
Returns the encoding used when the document was parsed. | String | DOM 3 |
Node.lastChild |
Returns the last child of a node | Node | |
document.lastModified |
Returns the date on which the document was last modified. | String | DOM 0 |
document.lastStyleSheetSet |
|||
document.linkColor Deprecated |
Gets/sets the color of hyperlinks in the document. | String | DOM 0 |
Name | Description | Return Type | Availability |
document.links |
Returns a list of all the hyperlinks in the document. | HTMLCollection | HTML |
Node.localName |
Returns the local part of the qualified name of this node (null for a document) | String | |
document.location |
Returns the URI of the current document. | Location [5] | DOM 0 |
Node.namespaceURI |
Returns the XML namespace of the current document. | All | |
Node.nextSibling |
Returns the node immediately following the specified one in its parent's childNodes list, or null if the specified node is the last node in that list (null for documents) | ||
Node.nodeName |
Returns the node's name (#document for document) | String | |
Node.nodeType |
Returns a node type constant (9 for document) | Number | |
Node.nodeValue |
Returns the node's value (null for document) | ||
Node.nodePrincipal New in Firefox 3 |
Returns the nsIPrincipal object representing current security context of the document. |
nsIPrincipal [6] |
All |
Node.ownerDocument |
Returns the top-level document object for this node (null if already is the document). | ||
Node.parentNode |
Returns the parent of the specified node in the DOM tree (null for document) | ||
document.plugins |
Returns a list of the available plugins. | HTMLCollection | DOM 0 |
document.popupNode |
Returns the node upon which a popup was invoked (XUL documents only). | Node [7] | XUL |
document.preferredStyleSheetSet |
|||
Node.prefix |
Returns the namespace prefix of the specified node, or null if no prefix is specified |
||
Node.previousSibling |
Returns the node immediately preceding the specified one in its parent's childNodes list, null if the specified node is the first in that list (null for document) |
||
document.readyState Requires Gecko 1.9.2 |
Returns loading status of the document | String | HTML5 |
document.referrer |
Returns the URI of the page that linked to this page. | String | HTML |
document.selectedStyleSheetSet |
|||
document.strictErrorChecking |
Returns true if error checking is enforced or false if it is not. |
Boolean | DOM 3 |
document.styleSheets |
Returns a list of the stylesheet objects on the current document. | StyleSheetList [8] | DOM 2 Style |
Node.textContent |
Returns null (returns other values for other nodes). | Null | DOM 3 |
document.styleSheetSets |
|||
document.title |
Returns the title of the current document. | String | HTML |
document.tooltipNode |
Returns the node which is the target of the current tooltip. | Node Object | XUL |
document.URL |
Returns a string containing the URL of the current document. | String | HTML |
document.vlinkColor Deprecated |
Gets/sets the color of visited hyperlinks. | String | DOM 0 |
document.width |
Returns the width of the current document. | Number | DOM 0 |
document.xmlEncoding |
Returns the encoding as determined by the XML declaration. | String | DOM 3 |
document.xmlStandalone |
Returns true if the XML declaration specifies the document is standalone (e.g., An external part of the DTD affects the document's content), else false . |
Boolean | DOM 3 |
document.xmlVersion |
Returns the version number as specified in the XML declaration or "1.0" if the declaration is absent. |
String | DOM 3 |
XPathExpression
which can then be used for (repeated) evaluations.
TreeWalker
object.
true
if the focus is currently located anywhere inside the specified document.
Firefox 3 introduces two new events: "online" and "offline". These two events are fired on the <body> of each page when the browser switches between online and offline mode. Additionally, the events bubble up from document.body, to document, ending at window. Both events are non-cancelable (you can't prevent the user from coming online, or going offline). For more info see Online and offline events.
When a new document is created, it initially gets "about:blank" loaded into it. In versions of Firefox prior to Firefox 3, "about:blank" documents didn't get the parent principle. This means that access to their contents was not restricted. While this doesn't seem like a significant issue, it can be if code proceeds to add content to the document using DOM methods and properties such as appendChild()
and so forth, because that content would not be protected from unauthorized access.
Firefox 3 updates Gecko so that new documents inherit the parent principle. This improves security both for iframe
s and documents that are in the process of being loaded, as well as for documents constructed programmatically.