html5本地缓存
使用js来控制html5的本地缓存,这里介绍两个简单的读取例子。如下:
增删改属性:
localStorage.setItem("key","value") //设置 localStorage.getItem("key","value") // 获取 localStorage.removeItem("key") // 删除 localStorage.clear() // 清空所有
实例:
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的值