遇到麻烦,由于某种原因,如果它位于同一页面index.html
,localstore var可以工作,但如果我把它移到我的site.js没有任何反应
var check = "Login as Admin";
var names = [];
var a = check;
names[0] = a;
localStorage["names"] = JSON.stringify(names);
var storedNames = JSON.parse(localStorage["names"]);
这有效
var check = "Login as Admin";
var names = [];
var a = check;
names[0] = a;
localStorage["names"] = JSON.stringify(names);
var storedNames = JSON.parse(localStorage["names"]);
if(storedNames == "Login as Admin"){
window.location="events_edit.html";
}