我使用创建工具栏按钮的Mozilla Addon Builder创建了扩展程序。没有对代码进行任何更改,该代码在当前稳定的FF 3中运行。
var mytestextension = {
onLoad: function() {
// initialization code
this.initialized = true;
this.strings = document.getElementById("mytestextension-strings");
},
onMenuItemCommand: function(e) {
var promptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
.getService(Components.interfaces.nsIPromptService);
promptService.alert(window, this.strings.getString("helloMessageTitle"),
this.strings.getString("helloMessage"));
},
onToolbarButtonCommand: function(e) {
// just reuse the function above. you can change this, obviously!
mytestextension.onMenuItemCommand(e);
}
};
window.addEventListener("load", mytestextension.onLoad, false);
出现工具栏按钮,但点击(我明白应该触发onToolbarButtonCommand)它什么都不做。我在这里调试时有点模糊:这是我第一次尝试使用“hello world'还没有工作!
答案 0 :(得分:1)