Hi, I'm trying to get my hands on the nsIDOMHTMLDocument from within a timer callback function. Below I've pasted in the code which I though should work but unfortunately isn't. I get the nsIDOMWindow and nsIDOMDocument just fine, but when I try to get the nsIDOMHTMLDocument from the nsIDOMDocument it fails - nsIDOMHTMLDocument is being returned as NULL. Does anyone have any ideas on what could be wrong or another way that I can do the same thing?
Thanks,
Damien
================
void MyMozilla::TimerCallback(nsITimer *aTimer, void *aClosure)
{
OutputDebugString(_T("In the timer...\n"));
nsCOMPtr<nsIWindowWatcher>
wwatch(do_GetService(NS_WINDOWWATCHER_CONTRACTID));
nsIDOMWindow *wind = NULL;
wwatch->GetActiveWindow(&wind);
if (wind)
{
nsIDOMDocument *dom_doc = NULL;
wind->GetDocument(&dom_doc);
if (dom_doc)
{
nsCOMPtr<nsIDOMHTMLDocument>
htmlDomDocument(do_QueryInterface(dom_doc));
if (htmlDomDocument)
{
OutputDebugString(_T("Gotcha!!!...\n"));
}
}
}
}
<<attachment: winmail.dat>>
