firefox扩展localStorage问题
我尝试将值保存在 localStorage 中,但它不起作用。也许我忘记了什么。首先我认为 localStorage 还不够,所以我将其扩展为 window.localStorage。我需要调用一些特殊的图书馆才能访问它吗?我的Firefox版本是3.5以上。
这是我的代码:
var ID1 = document.getElementById("id1");
var ID2 = document.getElementById("id2");
window.localStorage.setItem("IDF",JSON.stringify(ID1));
window.localStorage.setItem("IDS",JSON.stringify(ID2));
var RUN1 = JSON.parse(window.localStorage.getItem("IDF"));
var RUN2 = JSON.parse(window.localStorage.getItem("IDS"));
alert(RUN1 + RUN2);
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.stringify(ID2));
var RUN1 = JSON.parse(window.localStorage.getItem("IDF"));
var RUN2 = JSON.parse(window.localStorage.getItem("IDS"));
alert(RUN1 + RUN2);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯,
发现问题了:
如果将对象值分配给变量,也可以跳过 JSON:
hmmm,
found the problem:
you can skip JSON too if you assign the object value to the variables: