Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. function save_options() {
  2. var color = document.getElementById('color').value;
  3. chrome.storage.sync.set({
  4. favoriteColor: color
  5. }, function() {
  6. console.log("Color saved");
  7. });
  8. }
  9.  
  10. var color = null;
  11. chrome.storage.sync.get('favoriteColor', function(item){
  12. color = item.favoriteColor;
  13. //alert(color); //Here works;
  14. });
  15.  
  16. alert(color); // here doesn't work
  17.  
  18. var color = null;
  19. chrome.storage.sync.get('favoriteColor', function(item){
  20. color = item.favoriteColor;
  21. alertColor(color);
  22. });
  23.  
  24. function alertColor(color){
  25. alert(color);
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement