I'm trying to set a variable on one page and then display it on another page. Both pages exist on the same domain. I've never used sessionStorage before so I'm not really sure where I made my mistake. The second page is just a blank page for some reason. Here is the code on the first page that sets the variable.
if (typeof(Storage) != "undefined") {
// Store
sessionStorage.setItem("score", 12);
document.getElementById("result").innerHTML = ("score");
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
And here is the code on the second page that is supposed to retrieve the variable and print it to the screen.
if (typeof(Storage) != "undefined") {
// Retrieve
document.getElementById("result").innerHTML = sessionStorage.getItem("score");
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support Web Storage...";
}
Any insight on why this isn't getting the variable would be great thanks.