如何确定 Firefox 中的所有选项卡均已加载?
我正在编写一个 Firefox 插件,我需要能够在加载所有选项卡后运行一些代码。
我尝试了类似的方法:
window.addEventListener("load", function(e) {
gBrowser.addEventListener("load", function(ee) {
// code to run after all tabs have loaded
// thank user for installing my add-on
alert('Thank you for installing my add-on');
// add tab to my website
gBrowser.selectedTab = gBrowser.addTab("http://www.mywebsite.com/");
}, true);
}, false);
但这不起作用,因为这将在加载后运行每个选项卡的代码。我想等到所有选项卡都加载完毕。我想在用户安装我的附加组件后 Firefox 重新启动时打印一条警报消息。我还想向我的网站添加一个新选项卡。
我该怎么做?
I am writing a Firefox add-on and I need to be able to run some code after all the tabs have been loaded.
I tried something like:
window.addEventListener("load", function(e) {
gBrowser.addEventListener("load", function(ee) {
// code to run after all tabs have loaded
// thank user for installing my add-on
alert('Thank you for installing my add-on');
// add tab to my website
gBrowser.selectedTab = gBrowser.addTab("http://www.mywebsite.com/");
}, true);
}, false);
But this does not work because this will run the code for each tab after it is loaded. I want to wait until all of the tabs have loaded. I want to print an alert message when the Firefox restarts after the users installs my add-on. I also want to add a new tab to my website.
How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜你的意思是等到浏览器启动时会话恢复。您可以通过观察者服务收听发送的
sessionstore-windows-restored
通知。像这样的东西:I guess that you mean to wait until the session is restored when the browser starts up. There is a
sessionstore-windows-restored
notification sent out that you can listen to via observer service. Something like this: