0

I tried to use chrome.storage.local.get() to fetch the data but it was giving me an error saying Cannot read property 'local' of undefined.

I am trying to access this in the separate webpage which is not present in the chrome extension.

can any one please help me out over here???

Thanks in advance..

Trilok Nagvenkar
  • 896
  • 9
  • 14

1 Answers1

0

Rather than targetting a browser specific (and potentially buggy) storage method - why not use the HTML5 localStorage which has good browser support and is easy to implement:

to set:

localStorage.setItem("testItem","testValue");

to get:

var item = localStorage.getItem("testItem"); // gives "testValue"

Note that this method only stores strings and there is a session Storage option as well for when you don't want persistence. And it is not inherently secure so don't store sensitive data. But its REALLY useful for storing non-sensitive data and passing variables and values around webpages within your site. You can also use a checking mechanisim like Modernizr if you are worried that you clients may not have local storage (or a browsing in incognito mode) and therefore provide options or an alert for them.

gavgrif
  • 15,194
  • 2
  • 25
  • 27