Visit Mozilla.org

DOM:document.implementation

From MDC

« Gecko DOM Reference

Contents

[edit] Summary

Returns a DOMImplementation object associated with the current document.

[edit] Syntax

DOMImpObj = document.DOMImplementation

[edit] Example

var modName = "HTML";
var modVer = "2.0";
var conformTest = document.implementation.hasFeature(modName, modVer);

alert("DOM " + modName + " " + modVer + " supported?: " + conformTest);

// alerts with: "DOM HTML 2.0 supported?: true" if DOM Level 2 HTML module is supported.

A list of module names (e.g., Core, HTML, XML, etc) is available in the DOM Level 2 Conformance Section

[edit] Notes

The W3C's DOM Level 1 Recommendation only specified the hasFeature method, which is one way to determine if a DOM module is supported by a browser (see example above and What does your user agent claim to support?). If available, other DOMImplementation methods provide services for controlling things outside of a single document. For example, the DOMImplementation interface includes a createDocumentType method with which DTDs can be created for one or more documents managed by the implementation.

[edit] Specification

DOM Level 2 Core: implementation

[edit] Methods

  • createDocument(String namespaceURI, String qualifiedName, DocumentType doctype) - returns Document with root as specified in first two arguments, unless they are null in which case an empty document is created. This method may be useful if one is importing nodes from another document.
  • createDocumentType(String qualifiedName, String publicId, String systemId) - returns a DocumentType
  • hasFeature(String feature, String version); returns boolean