firefox扩展全局变量

firefox扩展全局变量,firefox,global-variables,Firefox,Global Variables,如何将事件函数中的值保存到firefox扩展中的全局变量中,或者还有其他更好的方法吗 代码: var bs= { onLoad:函数{…}, onPress:function{…}, onMenuItemCommand:function{…}, onToolbarButtonCommand:函数{…}, }; window.addEventListenerload,函数{bs.onLoad;},false; document.addEventListenerkeypress,函数{bs.onPr

如何将事件函数中的值保存到firefox扩展中的全局变量中,或者还有其他更好的方法吗

代码:

var bs= { onLoad:函数{…}, onPress:function{…}, onMenuItemCommand:function{…}, onToolbarButtonCommand:函数{…}, }; window.addEventListenerload,函数{bs.onLoad;},false; document.addEventListenerkeypress,函数{bs.onPresse;},false,true; 尝试在var bs之前初始化,但变量始终重置。

找到了解决方案

如果您这样声明变量:

window['variablename'] = "";

您可以在函数中访问它。

这将有助于了解有关您尝试执行的操作的更多信息。我想创建一个表单填充扩展。这没有什么区别。