implementation | NN 6 IE 5(Mac)/6(Win) DOM 1 | ||
The implementation object (the JavaScript reference for the W3C DOMImplementation object) represents, to a limited degree, the environment that makes up the document containerthe browser for our purposes. You can reach this object via the document.implementation property. |
|||
Methods of the object let you see which DOM modules the browser reports supporting. In Netscape 6, this object is also a gateway to creating virtual W3C Document and DocumentType objects outside of the current document tree. Thus, in Netscape 6 you can use the document.implementation property as a start to generating a nonrendered document for external XML documents. |
|||
Object Model Reference | |||
document.implementation |
|||
Object-Specific Properties | |||
None. |
|||
Object-Specific Methods | |||
|
|||
Object-Specific Event Handler Properties | |||
None. |
createDocument( ) | NN 6 IE n/a DOM 2 |
createDocument("namespaceURI", "qualifiedName", docTypeReference) | |
Returns a reference to a newly created virtual W3C DOM Document (not the document node of an HTML document) object. Netscape 6 extends this Document object with a load( ) method that permits the loading of XML documents into the browser, although they are invisible to the user. Scripts may then access the document tree of the XML document as a data source for rendering information in the HTML document. If you are loading an external XML document, you can create the Document object with blank values for the three parameters: var myXDoc = document.implementation.createDocument("", "", null); |
|
When the external document loads, any namespace and DOCTYPE concerns will be controlled by the document's content. For an example, see Section 5.9.2 in Chapter 5. |
|
Parameters | |
|
|
Returned Value | |
Reference to an empty Document object. |
createDocumentType( ) | NN 6 IE n/a DOM 2 |
createDocumentType("qualifiedName", "publicID", "systemID") | |
Returns a reference to a newly created virtual W3C DOM DocumentType object. You can feed the object returned from this method to the DocumentImplementation.createDocument( ) method. |
|
Parameters | |
|
|
Returned Value | |
Reference to a DocumentType object not yet associated with a Document object. |
hasFeature( ) | NN 6 IE 5(Mac)/6(Win) DOM 1 |
hasFeature("feature", "version") | |
Returns a Boolean true if the browser application supports (i.e., conforms to the required specifications of) a stated W3C DOM module and version. The closely related isSupported( ) method performs the same test on an individual node, allowing you to verify feature support for the current node type. Parameter values for the two methods are identical. |
|
It is up to the browser maker to validate that the DOM implemented in the browser conforms with each module before allowing the browser to return true for the module. That doesn't necessarily mean that the implementation is bug-free or consistent with other implementations. Caveat scriptor. |
|
In theory, you could use this method to verify module support prior to accessing a property or invoking a method. The following script fragment from the head portion of a document dynamically links a different external style sheet file for "true" CSS2 support: var cssFile; if (document.implementation.hasFeature("CSS", "2.0")) { cssFile = "styles/corpStyle2.css"; } else { cssFile = "styles/corpStyle1.css"; } document.write(<link rel='stylesheet' type='text/css' href='" + cssFile + "'>");" |
|
More browsers support this browser-wide method than the element-specific method, which may help more developers deploy it sooner. |
|
Parameters | |
|
|
Returned Value | |
Boolean value: true | false. |