Skip to content

Instantly share code, notes, and snippets.

@mikaelleven
Created March 4, 2015 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikaelleven/a9db2ed835a8a1fbb89b to your computer and use it in GitHub Desktop.
Save mikaelleven/a9db2ed835a8a1fbb89b to your computer and use it in GitHub Desktop.
AppAuthTest
<body>
<div id="xx">Hejsan</div>
<button type="button" value="Set the value" onclick="setIt();">Set the value</button>
</body>
function getIt() {
var objXX = document.getElementById("xx");
if(typeof(Storage) !== "undefined") {
// Code for localStorage/sessionStorage.
var curVal = localStorage.getItem("myval");
if(curVal == null)
objXX.innerText = 'Value not set!';
else
objXX.innerText = 'Value is: ' + curVal;
} else {
// Sorry! No Web Storage support..
alert("Sorry! No Web Storage support..");
}
}
function setIt() {
localStorage.setItem("myval", "new val " + new Date().toString());
getIt();
}
window.onload = function() {
getIt();
}
button
{
padding: 12px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment