Create  Edit  Diff  XUL Wiki  Index  Search  Changes  History  Source  RSS  wikifarm  Login

開いているすべてのウィンドウを得る

nsIWindowMediator を使った方法

var windowMediator = Components.classes["@mozilla.org/appshell/window-mediator;1"]
                          .getService(Components.interfaces.nsIWindowMediator);
var enumerator = windowMediator.getEnumerator(null);
while(enumerator.hasMoreElements()){
    var win = enumerator.getNext();
}

nsIWindowDataSource (RDF) を使った方法

var rdf = Components.classes['@mozilla.org/rdf/rdf-service;1']
                  .getService(Components.interfaces.nsIRDFService);
var wmDS = rdf.GetDataSource("rdf:window-mediator")
                   .QueryInterface(Components.interfaces.nsIWindowDataSource);
var wmRoot = Components.classes["@mozilla.org/rdf/container;1"]
                  .createInstance(Components.interfaces.nsIRDFContainer);
wmRoot.Init(wmDS, rdf.GetResource("NC:WindowMediatorRoot"));

var enumerator = wmRoot.GetElements();
while(enumerator.hasMoreElements()){
    var resource = enumerator.getNext().QueryInterface(Components.interfaces.nsIRDFResource);
    var win = wmDS.getWindowForResource(resource.Value);
}
Last modified:2004/12/21 23:08:03
Keyword(s):
References:[XUL Wiki]