hello I'm using this code to send variables to another page
function store () {
var first = "Foo Bar",
second = ["Hello", "World"];
localStorage.setItem("first", first);
localStorage.setItem("second", JSON.stringify(second));
location.href = "http://example/page2.html";
}
How can I check if the variable exists in PAGE2 and if no there, how can I redirect to homepage(PAGE1)?
CodePudding user response: