W3C home > Mailing lists > Public > www-dom@w3.org > July to September 2009

Re: How can I create a HTMLDocument from the DOMImplementation

From: Olli Pettay <Olli.Pettay@helsinki.fi>
Date: Tue, 18 Aug 2009 16:37:44 +0300
Message-ID: <4A8AAEA8.5080704@helsinki.fi>
To: Bo Yang <struggleyb.nku@gmail.com>
CC: www-dom@w3.org
On 8/18/09 4:14 PM, Bo Yang wrote:
> Hi,
>      The Core module define the DOMImplementation interface which is
> used to bootstrap the DOM, to create Document and DocumentType. But I
> can't find a way to create a specific type of Document from that
> interface. I mean, how can I create HTMLDocument from some
> DOMImplementation? Thanks!
> Regards!
> Bo

In Gecko one can do it for example this way:
var dt =
     "-//W3C//DTD HTML 4.01//EN",
var doc = document.implementation.createDocument(null, null, dt);

This behavior is based on DOM 3 Core
"Note that based on the DocumentType  given to create the document, the 
implementation may instantiate specialized Document  objects that 
support additional features than the "Core", such as "HTML" [DOM Level 2 

IIRC, not all browser engines support creating specialized document
objects based on document type.

Received on Tuesday, 18 August 2009 13:38:47 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:36:55 UTC