Javascript 访问firefox插件';s的功能来自一个简单的网站

Javascript 访问firefox插件';s的功能来自一个简单的网站,javascript,firefox,firefox-addon,Javascript,Firefox,Firefox Addon,有没有可能在一个插件中有一个函数库,假设我们有: notification(str){ $('#notification').text(str); } 如何从默认的html网站访问该功能 thx:)您需要使用导出功能 notification(str){ $('#notification').text(str); } exportFunction(notification, contentWindow, { defineAs: "addonNotification" })

有没有可能在一个插件中有一个函数库,假设我们有:

notification(str){
    $('#notification').text(str);
}
如何从默认的html网站访问该功能


thx:)

您需要使用
导出功能

notification(str){
    $('#notification').text(str);
}

exportFunction(notification, contentWindow, {
  defineAs: "addonNotification"
});
然后在网页中,使用
window.addonNotification(“hello notification!”)

有关更多信息:


插件必须使网站能够与其交互。不能反过来做。