Created
October 5, 2015 06:02
-
-
Save redknitin/b3a46d2bdac374ef2031 to your computer and use it in GitHub Desktop.
Session storage - Demo 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html><html> | |
<head> | |
<script> | |
function putInStorage() { | |
itemz = [1, 2, 3]; | |
sessionStorage.setItem("itemz", JSON.stringify(itemz)); | |
} | |
function getFromStorage() { | |
itemz = JSON.parse(sessionStorage.getItem("itemz")); | |
for (i=0; i<itemz.length; i++) { | |
alert(itemz[i]); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<button onclick="alert(window.sessionStorage.length);">Session Size</button> | |
<button onclick="putInStorage();">Set</button> | |
<button onclick="getFromStorage();">Get</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment