FF 3.5 extension: window.title is 'undefined'

1.1k Views Asked by At

From a sidebar in Firefox 3.5 I am getting a reference to the main window with:

var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
               .getInterface(Components.interfaces.nsIWebNavigation)
               .QueryInterface(Components.interfaces.nsIDocShellTreeItem)
               .rootTreeItem
               .QueryInterface(Components.interfaces.nsIInterfaceRequestor)
               .getInterface(Components.interfaces.nsIDOMWindow);

Then, mainWindow.title is undefined (this works in Firefox 3.0).

I've also tried:

mainWindow.getBrowser().selectedBrowser.contentWindow.title (also undefined)

and it might be worth noting that

mainWindow.getBrowser().selectedBrowser.contentWindow.location.href

returns the correct URL.

Thanks! Noah

2

There are 2 best solutions below

0
On BEST ANSWER

I think what you really want is mainWindow.content.document.title. The title attribute exists on a document, not a window and should work in 3.0 and beyond.

2
On

It was removed in bug 450977 after being deprecated since 2004.

If my reading of the bugs is correct, the correct replacement is document.title.