Home > Software design >  Check variable and send to home page with JS
Check variable and send to home page with JS

Time:03-11

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:

You need to check enter image description here

  • Related