我目前正在使用 Firefox add on sdk 制作 Firefox 扩展,我尝试在内容脚本(页面模块)和弹出窗口(面板)之间进行通信,但无济于事。
我正在使用 toolbar button埃里克沃尔德。这是我的代码:
var tbb = require('toolbarbutton').ToolbarButton({
id: 'from-us_button',
label: 'from-us',
image: data.url('img/on.png'),
panel: panel
});
var pageMod = require('page-mod').PageMod({
include: "*",
contentScriptFile: [
data.url('recuperation.js')
],
contentScriptWhen : "end",
attachTo: ["existing", "top"]
});
var panel = require('panel').Panel({
width: 200,
height: 500,
contentURL: data.url('popup.html')
});
我的 popup.html 包含:
<script type="text/javascript" src="popup.js"></script>
我想将一个变量从 recuperation.js 传递到 popup.js,我该怎么做?
最佳答案
在您的 popup.js 中,您应该有一个“插件”全局对象,它允许您将消息发送回 main.js。这记录在这里:
关于javascript - 内容脚本(页面模块)和弹出窗口(面板)之间的通信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16914155/