[Project_owners] How to create DOM element/node in XPCOM JS component?

Eric H. Jung grimholtz at yahoo.com
Wed May 24 15:39:38 EDT 2006


Correction:

var doc = Components.classes["@mozilla.org/xml/xml-document;1"] 
  .createInstance(Components.interfaces.nsIDOMDocument);
var a = d.createElement("foo");

This creates elements in the default namespace whereas
"@mozilla.org/xul/xul-document;1" creates elements in the
http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul
namespace.

--- "Eric H. Jung" <eric.jung at yahoo.com> wrote:

> Answering my own question:
> 
> var d = Components.classes["@mozilla.org/xul/xul-document;1"]
>   .createInstance(Components.interfaces.nsIDOMDocument);
> var a = d.createElement("foo");
> 
> 
> --- "Eric H. Jung" <eric.jung at yahoo.com> wrote:
> 
> > Hi,
> > 
> > I use the following code in overlays to create a DOM element:
> > 
> >   var doc = document.implementation.createDocument("", "", null);
> >   var foxyproxyElem = doc.createElement("foxyproxy");
> > 
> > But this code doesn't work in an XPCOM JS component--there is no
> > document. Is there an XPCOM service which can do this? If not, any
> > other way?
> > 
> > Thanks for any ideas,
> > Eric
> > _______________________________________________
> > Project_owners mailing list
> > Project_owners at mozdev.org
> > http://mozdev.org/mailman/listinfo/project_owners
> > 
> 
> 
> Use Your PC To Find a Cure for
>
Cancerhttp://members.ud.com/services/teams/team.htm?id=68C9E079-8285-495F-8598-D73352CC7075And
> Join Team Lulu
> _______________________________________________
> Project_owners mailing list
> Project_owners at mozdev.org
> http://mozdev.org/mailman/listinfo/project_owners
> 



More information about the Project_owners mailing list