为Google Chrome开发的扩展程序之间的通信

时间:2011-03-04 01:43:05

标签: plugins google-chrome google-chrome-extension

我为谷歌浏览器开发了两个扩展(比如扩展A和扩展名B)。扩展A使用Content-scripts.js A,扩展B使用content-scripts.js B.

在content-scripts.js A中,我使用了localStorage.setItem(“parameterVariable”,“hi”);

在content-scripts.js B中,我使用了localStorage.getItem(“parameterVariable”),假设返回“hi”,因为扩展A首先运行并设置“paraneterVariable”,而扩展B使用它。但它返回NULL。

如何使扩展名B的localStorage.getItem(“parameterVariable”)返回扩展名B设置的值。

提前致谢。

1 个答案:

答案 0 :(得分:2)

您可以使用chrome.extension模块。

只需在其中一个扩展上创建一个请求侦听器,然后在第二个扩展ID中发送请求。有关消息传递的更多详细信息here

相关问题