FF扩展程序导航回上一个站点

时间:2013-07-04 17:47:51

标签: javascript navigation firefox-addon mozilla

为ff开发新的插件我遇到了问题。

我有一个能够很好地触发的观察者,在某些情况下它应该导航回来。

e.g。我正在谷歌上冲浪,然后去另一个网站,我希望扩展程序能够导航回我来自的地方,在这种情况下是google。

我尝试了一些像

这样的东西
window.history.back();

window.history.go(-1);

然后我收到错误

[Exception... "Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIDOMHistory.back]"  nsresult: "0x80004005 (NS_ERROR_FAILURE)"  location: "JS frame :: chrome://testaddon/content/script.js :: httpRequestObserver.observe :: line 41"  data: no]

所以有人可以告诉我如何使用插件导航回来,就像我可以用左上角的箭头手动操作一样吗?

1 个答案:

答案 0 :(得分:1)

夜班,我明白了:

window.top.getBrowser().selectedBrowser.contentWindow.history.go(0);