localStorage 与 sessionStorage

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>localStorage  与 sessionStorage</title>
</head>

<body>
</body>
</html>

<script type="text/javascript">

var obj = { name:'Jim' }; 
var str = JSON.stringify(obj); 
 
//存入 
sessionStorage.obj = str; 
//读取 
str = sessionStorage.obj; 
//重新转换为对象 
obj = JSON.parse(str);





//localStorage 存储与读取
localStorage["local"]="你好";

//alert(localStorage.local);
</script>

 

posted @ 2016-03-15 16:11  328201736  阅读(162)  评论(0编辑  收藏  举报