HTML5 Web Storage

js文件里

浏览经过的时保存
sessionStorage.setItem(key,value);
value = sessionStorage.getItem(key);

sessionStorage.key = value;

本地保存
localStorage.setItem(key,value)
value = localStorage.getItem(key);

for(var i=0;i<localStorage.length;i++)
{
      var key = localStorage.key(i);
       var value = localStorage.getItem(key);
}


localStorage.clear()

简单数据库栗子

var data = new Object;

data.name = document.getElementById("name").value;
data.email = document.getElementById("email").value;
data.tel = document.getElementById("tel").value;
data.memo = document.getElementById("memo").value;

var str = JSON.stringify(data);  (JSON 存储)

localStorage.setItem(data.name,str);

 

var find = document.getElementById("find").value;
var str = localStorage.getItem(find);
var data = JSON.parse(str);
var result = data.name +data.email+data.tel+data.memo;

 

更多资料参考博客:

http://www.cnblogs.com/yuzhongwusan/archive/2011/12/19/2293347.html

posted @ 2016-07-11 10:19  joycefan  阅读(120)  评论(0编辑  收藏  举报