A Pen by Mikael Levén on CodePen.
Created
March 4, 2015 16:35
-
-
Save mikaelleven/a9db2ed835a8a1fbb89b to your computer and use it in GitHub Desktop.
AppAuthTest
This file contains hidden or 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
<body> | |
<div id="xx">Hejsan</div> | |
<button type="button" value="Set the value" onclick="setIt();">Set the value</button> | |
</body> |
This file contains hidden or 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
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(); | |
} | |
This file contains hidden or 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
button | |
{ | |
padding: 12px; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment