FF 3.5 extension: window.title is 'undefined'
-
21-09-2019 - |
Question
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
Solution
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.
OTHER TIPS
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
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow