如何在Firefox SDK插件中删除侦听器?

雾霾

在我的插件中,我想将图像从面板放置到页面上。一切正常,但是当我尝试在新选项卡中进行相同设置时,图像也插入了旧选项卡中。请向我解释,如何从旧选项卡中删除侦听器?

var tabIs;
var thisTab;

tabs.on("ready", function(tab) {
    tabIs = tab.id;
    tab.on("load", function(tab) {
        tabIs += 1;
    });
});

function handleClick() {
    function insertPic(pic) {
        var abs_url = self.data.url(pic);
        worker.port.emit("to-page", abs_url);
    }

    if (thisTab == tabIs) {
        panel.show();
        panel.port.on("from-panel", insertPic);
    } else {
        thisTab = tabIs;
        panel.show();
        var worker = tabs.activeTab.attach({
            contentScriptFile: [self.data.url("jquery-2.1.1.min.js"), self.data.url("page.js")]
        });
        panel.port.on("from-panel", insertPic);
    }
}
现实的

您需要在worker上调用destroy()方法,有关更多信息,请参阅文档

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章