Google chrome扩展程序:本地存储 [英] Google chrome extension: local storage
问题描述
我正在为Google Chrome开发扩展程序,并遇到了一些麻烦。我创建了一个options.html页面,并将其添加到manifest.json文件中。页面显示正确。
I'm developing an extension for Google Chrome, and have run into some trouble.I created an options.html page and added it to the manifest.json file.The page shows properly.
我保存了选项,然后返回到应该运行扩展的页面。
I saved the options, and then went back to the page on which the extension is supposed to run.
不幸的是,本地存储选项是返回一个'null'而不是选项。如果我直接从扩展的JS脚本中设置本地存储选项,它可以正常工作,但如果它是从选项页面设置的,则不会。
Unfortunately, the Local storage for the options was returning a 'null' instead of the option. If I set the local storage option directly from the extension's JS script, it works fine but not if it was set from the options page.
任何想法如何访问options.html我的Javascript文件中的本地存储值是否在扩展名中?
Any idea how i can access the options.html local storage values from my Javascript file in the extension?
推荐答案
have you set them using either:
localStorage["var"]=data;
或
localStorage.var=data;
,您是否使用
and are you loading them using
var myvar = localStorage.var;
您可以看到API 这里
这篇关于Google chrome扩展程序:本地存储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!