JavaScript localStorage is null on options page

In the options page of a chrome extension, localStorage is null and thus can not be used.
Here are the files of the unpacked extension producing error.

manifest.json

{
    "name": "someTest",
    "version": "1.0",
    "manifest_version": 2,
    "description": "Not important",
    "icons": {
        "16": "icon16.png",
        "48": "icon48.png"
    },
    "options_page": "options.html"
}

options.html

<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Just a test</title>
</head>
<body>
    <script src="options.js"></script>
</body>
</html>

options.js

console.log(localStorage);

Accessing the options page, the console outputs null. When trying to change or access a property using localStorage['property'], it throws an error since localStorage is null.

I tried something like localStorage = {property: 'value'}; but it did not change anything, after that localStorage was still null.

I'm using chrome 28.0.1500.95 on Windows 8.

Edit: The issue is still there. However, I -for the moment- use an alternative, if it can help someone. I now use chrome storage.

Here is how it works.

manifest.json

"permissions": ["storage"]

options.js

//You can also use an array of strings instead of 'property' to get multiple values.
chrome.storage.local.get('property', function(data)
{
    if(!data.propery) return; //Not set
    console.log(data.property);
});
chrome.storage.local.set({property: 'value'}, function()
{
    console.log('saved');
});
//It can be used the same way directly in content scripts.
Answer:1

I select an element of the page: $mainSection = $('#main'); then I add more Elements via AJAX into the <div id="main"></div> element. Next time I call $mainSection, the newly added ...

I select an element of the page: $mainSection = $('#main'); then I add more Elements via AJAX into the <div id="main"></div> element. Next time I call $mainSection, the newly added ...

  1. prevent element from scrolling
  2. prevent element from losing focus
  3. prevent element from inheriting css
  4. prevent element from getting focus
  5. prevent element from overflowing
  6. prevent element from moving css
  7. prevent element from scrolling css
  8. prevent elements from going to next line
  9. prevent element from being clicked
  10. prevent element from wrapping
  11. prevent element from being tabbed to
  12. prevent element from resizing
  13. prevent element from overlapping
  14. prevent element from drag
  15. prevent element from hover
  16. css prevent element from going off screen
  17. css prevent element from overflowing
  18. prevent flex element from growing
  19. css prevent element from wrapping
  20. html prevent element from getting focus

I have built a website but really struggling with easyslider and Internet explorer. It seems the Javascript is loading and then deciding against it for some reason. jQuery is included in the header ...

I have built a website but really struggling with easyslider and Internet explorer. It seems the Javascript is loading and then deciding against it for some reason. jQuery is included in the header ...

chart3 = new Highcharts.Chart({ chart: { renderTo: 'container3', type: 'column' }, title: { ...

chart3 = new Highcharts.Chart({ chart: { renderTo: 'container3', type: 'column' }, title: { ...

  1. javascript undefined variable works

This is my first attempt at writing a Firefox add-on. I'm trying to read a text file that is contained in an Firefox Add-on I'm writing. I'm following the example from MDN let decoder = new ...

This is my first attempt at writing a Firefox add-on. I'm trying to read a text file that is contained in an Firefox Add-on I'm writing. I'm following the example from MDN let decoder = new ...

  1. file // firefox open
  2. file firefox download
  3. file firefox bug
  4. file firefox passwords
  5. firefox file share
  6. firefox file transfer
  7. firefox file send
  8. firefox file hippo
  9. firefox file upload
  10. firefox file associations
  11. firefox file sender
  12. firefox file menu
  13. firefox file not found
  14. firefox file moved or missing
  15. firefox file manager
  16. firefox file location
  17. firefox file explorer
  18. firefox file browser
  19. firefox file drop
  20. firefox file url