Easing Back into Coding for the Web - Wednesday, Nov 30, 2022

  1. Click here for the W3School tutorial on HTML 5 Web Storage
  2. Create a new html document, using our starter template.
  3. Create a javascript function named getInfo() in the script area.
  4. In the <body> tag, add an onload event handler to trigger the getInfo function when the page loads.
  5. In the javascript function, add this code:
    var firstName = prompt("What is your first name?");
  6. Add another line similar to the one above to ask the user for their last name.
  7. Again, in the javascript, add this line to store the user's first name:
    localStorage.setItem("firstName", firstName);
  8. Do the same for lastName.

  9. Create another html document, using the template.
  10. Add two <p> elements, one with id="fName", the other with id="lName".
  11. Create a javascript function called loadInfo() and have it get triggered by an onload event.
  12. In the loadInfo() function add this line of code:
    document.getElementById("fName").innerHTML = "Welcome back, " + localStorage.firstName;
  13. Repeat the above step for lastName.
  14. Add code to each page to link them.
  15. Can you think of anything that could go wrong?