Hi, I've managed to get this working using nsIDOMXULCommandDispatcher. In short the sequence I went through is as follows; 1) Get an nsIWindowWatcher 2) Using windowWatcher get the active window (GetActiveWindow()) 3) Get the DOM document associated with that window (nsIDOMDocument) 4) QueryInterface the DOM document for the nsIDOMXULDocument 5) Using nsIDOMXULDocument get the nsIDOMXULCommandDispatcher (GetCommandDispatcher()) 6) Using commandDispatcher you can get the focused window (GetFocusedWindow()) 7) From the nsIDOMWindow returned by GetFocusedWindow() you get it's DOM document. 8) Finally you QI that DOM document to get the nsIDOMHTMLDocument from which you can access title, URL info, etc..
I've done some initial testing of my component with Firefox v1.0.2, Netscape v7.2 and Mozilla v1.7.6 - it works fine with all of them. Christian: Good call on asking the mozilla DOM mailing list - they helped a lot. > > nsIDOMWindow *wind = NULL; > > wwatch->GetActiveWindow(&wind); > > FWIW, you are leaking the window here. Can I ask one other question - you say above that I'm leaking the window in this piece of code - do you mean leaking memory? If so is the right thing to do to use something like nsMemory::Free to clean this up once I'm done using this pointer? Thanks, Damien > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Christian Biesinger > Sent: 22 April 2005 14:44 > To: [email protected] > Subject: Re: Problem getting nsIDOMHTMLDocument from within a > timer callback > > > netscape.public.mozilla.dom would be a better place for this > question, > I think... > > Damien O'Brien wrote: > > nsIDOMWindow *wind = NULL; > > wwatch->GetActiveWindow(&wind); > > FWIW, you are leaking the window here. > > > if (wind) > > { > > nsIDOMDocument *dom_doc = NULL; > > wind->GetDocument(&dom_doc); > > And the document. > > > nsCOMPtr<nsIDOMHTMLDocument> > > > htmlDomDocument(do_QueryInterface(dom_doc)); > > This will be an XUL document representing the browser chrome, not the > HTML document loaded inside it. > _______________________________________________ > Mozilla-xpcom mailing list > [email protected] > http://mail.mozilla.org/listinfo/mozilla-xpcom > _______________________________________________ Mozilla-xpcom mailing list [email protected] http://mail.mozilla.org/listinfo/mozilla-xpcom
