html5本地存储(localStorage)使用介绍

1、html5几种存储形式

本地存储(localStorage && sessionStorage)

离线缓存(application cache)

indexedDB 和 webSQL

2、localStorage && sessionStorage

过期时间:localStorage 永久存储,永不失效除非手动删除

sessionStorage 浏览器重新打开后就消失了

大小:每个域名是5M

3、localStorage API和sessionStorage API一致

getItem //取记录

setIten//设置记录

removeItem//移除记录

key//取key所对应的值

clear//清除记录

4、存储的内容

数组,图片,json,样式,脚本。。。(只要是能序列化成字符串的内容都可以存储)

posted @ 2016-10-23 16:49  雄霸烽火狼  阅读(321)  评论(0编辑  收藏  举报