在我的插件中,我想将图片从我的面板放到页面上。一切正常,但是当我尝试在新标签中进行相同操作时,图像也会插入旧标签中。请解释一下,如何从旧标签中删除监听器?
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);
}
}