Noah Watkins
Noah Watkins

Reputation: 5540

FF 3.5 extension: window.title is 'undefined'

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

Upvotes: 1

Views: 1166

Answers (2)

Nickolay
Nickolay

Reputation: 32073

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.

Upvotes: 0

sdwilsh
sdwilsh

Reputation: 4682

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.

Upvotes: 1

Related Questions