维护Google Chrome扩展程序中的数据

时间:2012-07-09 17:40:09

标签: javascript html google-chrome google-chrome-extension

示例

  1. 点击我的扩展程序

  2. 打开我的扩展程序的html页面(popup.html)

    enter image description here

  3. 我添加了一个包含文本的元素,即提示文本

    enter image description here

  4. “放弃”扩展名

  5. 控制列表框,插入的新第一个元素不在列表框中

    enter image description here

  6. 有我的

    popup.html

2 个答案:

答案 0 :(得分:3)

想象一下,你打开了一个文本文件,在其中写了一些文字并没有保存它?您认为会发生什么?

您需要在某处保存内容的状态,这可以使用localStorage来完成。

这篇文章解释了所有相关内容:

http://coding.smashingmagazine.com/2010/10/11/local-storage-and-how-to-use-it/

答案 1 :(得分:1)

优于HTML5 localStorage,请考虑利用chrome.storage API