Got a big problem, when I update my localStorage with my Options page it's OK, new values are stored but my background.js keeps the values of the first load even if I put something like :
var value = localStorage['item'];
When I refresh the extension it's OK but very annoying...
There is any fix about that?
Regards
Are you sure? Are you keeping in mind that the script on the background page only gets executed once, when the extension first loads. So you need to tell the background page that the localStorage item has updated and to update your variable. Or your backgrounds code could just always access localStorage instead of using a variable.
As an example, this code will execute a function in the background page that will update the variable value....
background
// the following line will only be executed when the extension first loads
var value = localStorage['setting'];
function updateSetting () {
value = localStorage['setting'];
}
options
localStorage['setting']=Math.random();
chrome.extension.getBackgroundPage().updateSetting();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With