Using JavaScript, is it possible to save all variables on a page to local storage, and then re-load the stored variables when the page is refreshed or reloaded? I'm trying to save the variables to local storage and load them when the page is refreshed. This is what I've tried so far:
function saveAllVariables(){
//save all variables on the page to local storage
}
function loadAllVariables(){
//load all variables on the page from local storage, and re-create them using their original names
}
loadAllVariables(); //load all variables that were previously stored
if(typeof theName == "undefined"){
var theName = prompt("Please enter your name:","Your name");
}
if(typeof currentTime == "undefined"){
var currentTime = new Date();
}
document.body.innerHTML += "Time last visited: " + currentTime + "<br />";
document.body.innerHTML += "Your name : " + theName + "<br />";
var currentTime = new Date();