开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜