附加SDK工具栏按钮在第二个窗口中不起作用

时间:2013-09-12 11:27:13

标签: javascript firefox firefox-addon firefox-addon-sdk

我是一名JavaScript初学者,因此我尝试使用add-on builder创建一个Firefox工具栏按钮。该按钮工作正常并显示弹出窗口,但是当我打开第二个Firefox窗口时,该按钮不会显示。

守则:

exports.main = function() { 
var self = require("sdk/self");
var data = self.data;
//  var tabs = require('tabs');



function listTabs() {
var tabs = require("sdk/tabs");
for each (var tab in tabs)
console.log(tab.url);
}



var Request = require("sdk/request").Request;

var pageMod = require("sdk/page-mod");

// This module exports a single constructor function Panel which constructs a new panel.
// A panel is a dialog. Its content is specified as HTML and you can execute scripts in it,
// so the appearance and behaviour of the panel is limited only by what you can do using HTML, CSS and JavaScript.
var toolbar_popup = require("sdk/panel").Panel({
    width:200,
    height:280,
    contentURL: data.url("popup.html"),
    contentScriptFile: [data.url('js/jquery.js'), data.url('js/jquery.cookie.js'), data.url('js/popup.js')],
    contentScriptWhen:'ready',
    contentScript: " "+
  "self.port.on('curTabMsg', function(curTabMsg) {" +
    "main(curTabMsg['curTab']);" +
  "});"
});



// creating toolbarbutton via including toolbar library Toolbar Buttons.
// Through this an Icon has to be created on the toolbar with image name gse_icon_16x16.png
var tbb = require("toolbarbutton").ToolbarButton({
    id: "XXXXXX",
    label: "XXXXXXX",
    image: data.url("icon16.png"),
    panel: toolbar_popup,
    onClick: function() {   
  toolbar_popup.port.emit("curTabMsg",{'curTab': tabs.activeTab.url}); 
}
});



if (require('self').loadReason == "install") {
    tbb.moveTo({
        toolbarID: "nav-bar",
        forceMove: false // only move from palette
    });
}

toolbar_popup.on("show", function()  {
    toolbar_popup.port.emit("show", {
        version:self.version
        });
});

};

为什么按钮不显示在第二个窗口中?

0 个答案:

没有答案