2016-04-17 48 views
1

我想通過https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/panel中的建議去使用contentScript更新面板中的內容。目前,我有一臺服務器返回我想在我的面板中顯示的HTML。我做panel.postMessage("update_panel", contents);當我有響應準備,並與包含在Firefox擴展中更新面板內容

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

function handleMessage(message) { 
    document.write(message); 
} 

不過,我沒有看到任何更新面板相關的contentScriptFile,我也無法調試contentScriptFile(是有辦法做到這一點?)。

我在做什麼錯?

回答

0

我最終找出了一些東西。

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

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

如果任何人可以解釋爲什麼這個工作和postMessage不會,那會很好。