jsStorage.js实现对html5的localstorage和sessionStorage的封装操作;
详情请阅读: https://git.oschina.net/wuquanyao/JsStorage/*+==============================================<br>
+ 我不只是一个程序员,我更希望用此创造价值<br>
+ author:wuquanyao<br>
+ email:wqynqa@163.com<br>
* version:1.0.0 <br>
+==============================================*/<br>
var storage=(function(){<br>
var Storage = function(type){<br>
this.storage = null;<br>
if(typeof('type') === 'undefined' || type === 'local')<br>
this.storage = window.localStorage;<br>
else if(type === 'session')<br>
this.storage = window.sessionStorage;<br>
}<br>
Storage.prototype.set=function(key, value){<br>
this.storage.setItem(key, escape(value));<br>
}<br>
Storage.prototype.get=function(key){<br>
return unescape(this.storage.getItem(key));<br>
}<br>
Storage.prototype.remove=function(key){<br>
this.storage.removeItem(key);<br>
}<br>
Storage.prototype.clear=function(){<br>
this.storage.clear();<br>
}<br>
Storage.prototype.key=function(index){<br>
return this.storage.key(index);<br>
}<br>
Storage.prototype.hasKey=function(key)<br>
{<br>
for(var i in this.storage){<br>
if(i === key){<br>
return true;<br>
}<br>
}<br>
return false;<br>
}<br>
Storage.prototype.hasVal=function(value)<br>
{<br>
for(var i in this.storage){<br>
if(unescape(this.storage[i]) === value){<br>
return true;<br>
}<br>
}<br>
return false;<br>
}<br>
Storage.stringify = function(data){<br>
return JSON.stringify(data);<br>
}<br>
Storage.parse = function(data){<br>
return JSON.parse(data);<br>
}<br>
Storage.support = function(){<br>
if(window.localStorage && window.sessionStorage) return true;<br>
return false;<br>
}<br>
return Storage;<br>
})(window);
AD:真正免费,域名+虚机+企业邮箱=0元