开发者

firefox extension localStorage problem

I tried to save values in localStorage but it does not work. Maybe I forgot something. First I was thinking localStorage was not enough so I extended it to window.localStorage. Do I have to call some special library to access it? My Firefox version is above 3.5.

Here is my code:

var ID1 = document.getElementById("id1");
var ID2 = document.getElementById("id2");

window.localStorage.setItem("IDF",JSON.stringify(ID1));
window.localStorage.setItem("IDS",JSON.str开发者_开发问答ingify(ID2)); 

var RUN1 = JSON.parse(window.localStorage.getItem("IDF"));
var RUN2 = JSON.parse(window.localStorage.getItem("IDS"));

alert(RUN1 + RUN2);         


hmmm,

found the problem:

window.content.localStorage.setItem

you can skip JSON too if you assign the object value to the variables:

var IDF = ID1.value
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜