可怜的浏览器兼容问题 FF API

 可怜的浏览器兼容问题,。只有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.

 

Properties

Name Description Return Type Availability
document.activeElement Returns the currently focused element Element HTML 5
document.alinkColorDeprecated 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.bgColorDeprecated 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.fgColorDeprecated 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.linkColorDeprecated 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

Methods

document.addEventListener
Adds an event listener to the document.
document.adoptNode New in Firefox 3
Adopt node from an external document
Node.appendChild
Adds a node to the end of the list of children of a specified parent node.
document.captureEvents
document.clear* Deprecated
In majority of modern browsers, including recent versions of Firefox and Internet Explorer, this method does nothing.
Node.cloneNode
Makes a copy of a node or document
document.close*
Closes a document stream for writing.
Node.compareDocumentPosition
Compares the position of the current node against another node in any other document.
document.createAttribute
Creates a new attribute node and returns it.
document.createAttributeNS
Creates a new attribute node in a given namespace and returns it.
document.createCDATASection
Creates a new CDATA node and returns it.
document.createComment
Creates a new comment node and returns it.
document.createDocumentFragment
Creates a new document fragment.
document.createElement
Creates a new element with the given tag name.
document.createElementNS
Creates a new element with the given tag name and namespace URI.
document.createEntityReference
Creates a new entity reference object and returns it.
document.createEvent
Creates an event.
document.createExpression 
Compiles an XPathExpression which can then be used for (repeated) evaluations. 
document.createNSResolver
Creates an XPathNSResolver.

document.createProcessingInstruction
Creates a new processing instruction element and returns it.
document.createRange
Creates a Range object.
document.createTextNode
Creates a text node.
document.createTreeWalker
Creates a TreeWalker object.
document.elementFromPoint New in Firefox 3
Returns the element visible at the specified coordinates.    
document.evaluate
Evaluates an XPath expression.
document.execCommand*
Executes a Midas command.
document.execCommandShowHelp
document.getBoxObjectFor
document.getElementById
Returns an object reference to the identified element.
document.getElementsByClassName New in Firefox 3
Returns a list of elements with the given class name.
document.getElementsByName
Returns a list of elements with the given name.
document.getElementsByTagName
Returns a list of elements with the given tag name.
document.getElementsByTagNameNS 
Returns a list of elements with the given tag name and namespace.  
Node.getFeature
document.getSelection
Node.getUserData
Returns any data previously set on the node via setUserData() by key
Node.hasAttributes
Indicates whether the node possesses attributes
Node.hasChildNodes
Returns a Boolean value indicating whether the current element has child nodes or not.
document.hasFocus
Returns true if the focus is currently located anywhere inside the specified document.  
document.importNode
Returns a clone of a node from an external document
Node.insertBefore
Inserts the specified node before a reference node as a child of the current node.
Node.isDefaultNamespace
Returns true if the namespace is the default namespace on the given node
Node.isEqualNode
Indicates whether the node is equal to the given node
Node.isSameNode
Indicates whether the node is the same as the given node
Node.isSupported
Tests whether the DOM implementation implements a specific feature and that feature is supported by this node or document
document.load
Load an XML document
document.loadOverlay New in Firefox 1.5
Loads a XUL overlay dynamically. This only works in XUL documents.
Node.lookupNamespaceURI
Returns the namespaceURI associated with a given prefix on the given node object  
Node.lookupPrefix
Returns the prefix for a given namespaceURI on the given node if present
Node.normalize
Normalizes the node or document
document.normalizeDocument
Replaces entities, normalizes text nodes, etc.
document.open*
Opens a document stream for writing.
document.queryCommandEnabled*
Returns true if the Midas command can be executed on the current range.
document.queryCommandIndeterm*
Returns true if the Midas command is in a indeterminate state on the current range.
document.queryCommandState*
Returns true if the Midas command has been executed on the current range.

document.queryCommandSupported

document.queryCommandText

document.queryCommandValue*
Returns the current value of the current range for Midas command. As of Firefox 2.0.0.2, queryCommandValue will return an empty string when a command value has not been explicitly set.
document.querySelector New in Firefox 3.5
Returns the first Element node within the document, in document order, that matches the specified selectors.
document.querySelectorAll New in Firefox 3.5
Returns a list of all the Element nodes within the document that match the specified selectors.

document.releaseEvents

Node.removeChild
Removes a child node from the DOM
document.removeEventListener
Removes an event listener from the document
document.renameNode
Change the name of an element or attribute node
Node.replaceChild
Replaces one child node of the specified node with another

document.routeEvent

Node.setUserData
Attaches arbitrary data to a node, along with a user-defined key and an optional handler to be triggered upon events such as cloning of the node upon which the data was attached
document.write*
Writes text to a document.
document.writeln
Write a line of text to a document.

Event handlers

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.

document.ononline New in Firefox 3
Returns the event handling code for the online event.
document.onoffline New in Firefox 3
Returns the event handling code for the offline event.
document.onreadystatechange Requires Gecko 1.9.2
Returns the event handling code for the readystatechange event.

Security notes

Firefox 3 note

This section covers security improvements made in Firefox 3/Gecko 1.9.

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 iframes and documents that are in the process of being loaded, as well as for documents constructed programmatically.

posted @ 2009-11-20 13:34  window5549-accp  阅读(625)  评论(0编辑  收藏  举报