浏览器的HTML5本地存储对于Firefox附加组件并不持久

时间:2015-08-05 06:45:49

标签: javascript html5 firefox-addon local-storage

我正在编写一个Firefox附加组件,它使用浏览器的本地存储来存储两个变量的值。当使用这是一般HTML页面的形式时,我甚至在关闭浏览器之后获得本地存储变量的值,但是当我通过加载项加载此页面后尝试执行相同操作时,我获取本地存储变量的空值。

我可以在这两种情况下使用局部变量,直到我关闭浏览器。但是在重新启动浏览器的情况下,加载项的本地变量值将丢失

用于执行此操作的脚本如下: -

//Fetching the values in the various fields.
//Usermail and password are the ids of two input boxes
//Login is the id for an input button

var id = document.getElementById("usermail");
var pass = document.getElementById("password");
var login = document.getElementById("login");

//Saving the values for the id and password fields

login.addEventListener("click", function() {
    localStorage.setItem("Email", id.value );
    localStorage.setItem("Password", pass.value);
    login_Email = localStorage.getItem("Email"); 
    login_pass = localStorage.getItem("Password"); 
    alert(login_Email); // To check the local storage values 
});

需要加载项来存储用户的登录信息,以提供对邮件收件箱的访问权限并显示待处理的未读邮件数。需要安全地存储此数据,直到用户为此数据启动删除请求或启动注销请求为止。

0 个答案:

没有答案