views:

59

answers:

1

Hello, Im making firefox extension and I have a problem with variables. Extension works with file (chrome://myextension/content/document.html) opened in few tabs. I want it to store a value in each tab, so I decided to store it in one of the html objects, that have got "Object" id:

data="foobar"
node=gBrowser.contentDocument.getElementById("ObjectId");
node.setUserData('data', data, {handle:function () {}});

For some reason, this doesn't work, when I want to get this variable in this way:

data=node.getUserData("data");

Can you spot an error in my code?

PS. This two pieces of code are separated methods. The html file is on a hard disk

+1  A: 

Do you set it and get it in the same document (tab) without reloading in between? That works for me.

If you're trying to persist the stored value across the reloads or share a value between all tabs that have the same document loaded, you've picked the wrong API as far as I can tell (the spec is rather long and I didn't bother to confirm that).

What are you actually trying to do?

Nickolay