localStorage用法
if(window.localStorage){
alert('这个浏览器支持本地存储');
}else{
alert('这个浏览器支持不本地存储');
}
localStorage.a=3;//设置a为"3"
localStorage["a"]="sfsf";//设置a为"sfsf",覆盖上面的值
localStorage.setItem("b","isaac");//设置b为"isaac"
var a1 = localStorage["a"];//获取a的值
var a2 = localStorage.a;//获取a的值
var b=localStorage.getItem("b");//获取b的值
localStorage.removeItem("c");//清除c的值
localStorage.removeItem("a")
通过localStorage.key(i)---取出所有key localStorage.getItem( localStorage.key(i))--通过key取出所有value
var localStorage = window.localStorage;
for(var i=0;i<localStorage.length;i++){
alert(localStorage.key(i)+" "+localStorage.getItem( localStorage.key(i)))
}