Firefox addon 在Firefox扩展中更新面板内容

Firefox addon 在Firefox扩展中更新面板内容,firefox-addon,content-script,Firefox Addon,Content Script,我试图按照建议使用contentScript来更新面板中的内容。目前,我有一个服务器,它返回我想在面板中显示的html。我做panel.postMessage(“更新面板”,内容)当我准备好响应,并且有一个contentScriptFile与包含 self.port.on("update_panel", handleMessage); function handleMessage(message) { document.write(message); } 但是,我看不到任何更新,而且

我试图按照建议使用contentScript来更新面板中的内容。目前,我有一个服务器,它返回我想在面板中显示的html。我做
panel.postMessage(“更新面板”,内容)当我准备好响应,并且有一个contentScriptFile与包含

self.port.on("update_panel", handleMessage);

function handleMessage(message) {
    document.write(message);
}
但是,我看不到任何更新,而且我也无法调试contentScriptFile(有办法吗?)


我做错了什么?

我终于想出了办法

panel.port.on("updating_done", function(response) {
    console.log(response);
});

panel.port.emit("update_panel", contents);

如果有人能解释为什么这是有效的,而postMessage却没有,那就太好了。

我最终找到了答案

panel.port.on("updating_done", function(response) {
    console.log(response);
});

panel.port.emit("update_panel", contents);
如果有人能解释为什么这行得通而postMessage不行,那就太好了