chrome.storage.sync.get Alert not working
chrome.storage.sync.get Alert not working
我已经保存了这个设置:
function save_options() {
var tbColor = document.getElementById('Color').value;
chrome.storage.sync.set({
'tbColor': Color
}, function() {
var status = document.getElementById('status');
status.textContent = 'Settings were saved.';
setTimeout(function() {
status.textContent = '';
}, 750);
});
}
现在我试着通过
查看设置 alert(chrome.storage.sync.get({'tbColor'}));
但是我什么也没得到(没有警报显示)。我知道整体的东西是工作的,因为alert("Hello");
工作。
我得到这些设置做错了什么?我是新来的,所以请对我宽容点:)
{'tbColor'}
语法无效,因此首先出错。
另外,chrome.storage.sync.get
是异步的,所以你不能使用返回值。
你可以使用:
chrome.storage.sync.get("tbColor", function(sync) {
alert(sync.tbColor);
});
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working