如何在浏览器启动运行 [英] How to run on browser start

查看:148
本文介绍了如何在浏览器启动运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var 我是Firefox插件开发的新手。
我有以下代码: windows = require(sdk / windows)。browserWindows;
windows.on(open,function(){
// do stuff
});

但是,这只适用于浏览器启动后创建的窗口,而不是第一个。

我该如何解决这个问题?



我知道我可以在开放事件之外复制代码,但是也可以运行时,插件安装,我不希望这样。

解决方案

我找到了答案这里

  exports.main = function(options,callbacks){
if(options.loadReason ==startup){
//做东西
}
};


I'm new to Firefox addon development.
I have the following code:

var windows = require("sdk/windows").browserWindows;
windows.on("open", function() {
    // do stuff
});

But this only runs for windows created after the browser is started, not the first one.
How can I fix this?

I know I could just copy the code outside of the open event, but then it also runs when the addon is installed and I don't want that.

解决方案

I found the answer here.

exports.main = function (options, callbacks) {
    if (options.loadReason == "startup") {
        // do stuff     
    }
};

这篇关于如何在浏览器启动运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆