在Firefox 3.5我得到一个参考主窗口侧边栏:FF 3.5扩展:window.title是“未定义”
var mainWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindow);
然后,mainWindow.title
是不确定的(这在Firefox 3.0) 。
我也试过:
mainWindow.getBrowser().selectedBrowser.contentWindow.title (also undefined)
,它可能是值得注意的是,
mainWindow.getBrowser().selectedBrowser.contentWindow.location.href
返回正确的URL。
谢谢! 诺亚
如果你的脚本在主窗口browser.xul中运行,那么'document.title'就可以工作。我不希望它从侧边栏工作,但我没有尝试,所以我不知道。 – MatrixFrog
是的,“document.title”会返回侧边栏的标题而不是真正的标题,但是OP明确知道如何从侧边栏上下文到browser.xul窗口。 – Nickolay