9

Trying to set and get values in my Chrome extension using local storage. Don't know what I did, but it's no longer working.¨

In manifest I have:

   "permissions": [
      "tabs", "http://*/*", "https://*/*", "storage"
    ],

This is the complete js, which sets a value and then tries to read it:

 chrome.storage.local.set({'userid': "foo"}, function (result) {
    chrome.storage.local.get('userid', function (result) {
        alert(userid.result);
   });
});

The alert says "undefined", not "foo" as expected.

The js is executed when i go to a certain page, specified in manifest for "content_scripts".

4

1 回答 1

12

呵呵,我想通了。它应该是:

alert(result.userid);

(反向用户ID和结果)

于 2013-04-30T15:19:46.397 回答