javascript - FF 3.5 扩展名 : window. 标题为 'undefined'

标签 javascript firefox firefox-addon firefox3.5

从 Firefox 3.5 的侧边栏中,我得到了对主窗口的引用:

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。

谢谢! 诺亚

最佳答案

我认为你真正想要的是mainWindow.content.document.title。 title 属性存在于文档中,而不是窗口中,并且应该在 3.0 及更高版本中工作。

关于javascript - FF 3.5 扩展名 : window. 标题为 'undefined',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1364596/

相关文章:

html - 使用 Helvetica 时,Firefox 和 Chrome 上 <button> 内的文本垂直对齐

perl - 我的浏览器显示 perl.cgi 脚本的内容而不是执行?

javascript - Firefox 扩展中的对象字面量

javascript - Components.classes 错误 - VS 2013 中的 FireFox 附加组件(扩展)

javascript - 如何在 ng serve 上缩小 vendor.js

javascript - 获取不按顺序排列的数组结果

javascript - JS/jQuery 对象

css - 在 firefox 和 chrome 上打印 viewer bird 报告中的 pdf 文件

firefox-addon - Firefox SDK 简单存储和 Firefox 同步

javascript - 服务器上存储的示例歌曲