Answer the question
In order to leave comments, you need to log in
Saving settings in popup.html (Chrome extension)
I want to save the state of the checkbox in the popup.html window. Problem: Every time the popup window is opened, the checkbox is reset to the default state. When a checkbox is clicked, its state is stored in localStorage. The problem is to restore the saved state when the popup window is reopened.
What I tried: tk. js just doesn't work like that, I tried to bind the function like this:
document.addEventListener("DOMContentLoaded" , function () {
document.getElementById("bd").addEventListener( "load" , clickTwo);
});
Answer the question
In order to leave comments, you need to log in
Just recently I solved a similar problem like this:
I wrote all changes in popup.html to the repository:
var obj = {
checkbox: 'checked'
};
chrome.storage.local.set(obj);
chrome.storage.local.get('checkbox', function (result) {
var checkboxState = result['checkbox'];
// result['checkbox'] вернёт undefined если такого имени ключа нет в хранилище
// ...
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question