Web storage blog 2
<!Doctype html>
<html>
<head>
<script type="text/javascript">
var key='string';
function pageLoad()
{
}
function loadNextPage()
{
var val = document.getElementById('fn').value;
var val2 = document.getElementById('ln').value;
var val3 = document.getElementById('c').value;
// local storage
window.localStorage.setItem("FN",val);
window.localStorage.setItem("LN",val2);
window.localStorage.setItem("C",val3);
// session storage
window.sessionStorage.setItem("F",val);
window.sessionStorage.setItem("L",val2);
window.sessionStorage.setItem("C",val3);
/*window.location.href="webstorage2.html"; */
}
function GetLocal()
{
alert(window.localStorage.getItem("FN"));
alert(window.localStorage.getItem("LN"));
alert(window.localStorage.getItem("C"));
}
function GetSession()
{
alert(window.sessionStorage.getItem("F"));
alert(window.sessionStorage.getItem("L"));
alert(window.sessionStorage.getItem("C"));
}
function Nav()
{
window.location.href="webstorage2.html";
}
</script>
</head>
<body onload='pageLoad()'>
First Name: <input type="text" name="fn" id="fn"/>
Last Name : <input type="text" name="ln" id="ln"/>
City : <input type="text" name="c" id="c"/>
<input type="button" onclick='loadNextPage()' value="Set Storage"/>
<input type="button" onclick='GetLocal()' value="Get Local"/>
<input type="button" onclick='GetSession()' value="Get Session"/>
</body>
</html>
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home