firefox extension global variable
How can I save values from an event function into a global variable in firefox extension or is there another better way?
Code:
var bs =
{
onLoad: function() {...},
onPress: function(e) {...},
onMenuItemCommand: function(e) {...},
开发者_运维技巧 onToolbarButtonCommand: function(e) {...},
};
window.addEventListener("load", function () { bs.onLoad(); }, false);
document.addEventListener("keypress", function(e) {bs.onPress(e); }, false, true);
Tried to initialize before var bs
but the variable is always reset.
Found the solution,
If you declare the variable like this:
window['variablename'] = "";
you can access it in your functions.
精彩评论