摘要: 用过localStorage都知道,它可以缓存数据在客户端,但是大小有限制。于是我这边想到了3种办法解决:1、获取字节数,当超过限制就自动全部清空var getBytes= function (str){ var len = str.length; var bytes = len; for(var i=0; i<len; i++){ if (str.charCodeAt(i) > 255) bytes++; } return bytes; }, maxSize= 5, //最大限制5MB ... 阅读全文
posted @ 2013-01-12 23:01 一只柯楠 阅读(842) 评论(0) 推荐(0) 编辑