//存本地缓存
function setLocal(name,val){
var strStorage = localStorage.getItem("storageData");
var arrStorage = JSON.parse(strStorage);
var objStorage = {};
objStorage.name = name;
objStorage.val=val;
if(arrStorage instanceof Array){
if (arrStorage.length>0&&arrStorage!=null){
var hasin = false;
for(var arr=0;arr<arrStorage.length;arr++){
if(name==arrStorage[arr].name){
objStorage = arrStorage.splice(arr,1,objStorage);
hasin = true;
}
}
if(hasin == false){
arrStorage.push(objStorage);
}
}
}else{
arrStorage=[];
arrStorage.push(objStorage);
}
localStorage.setItem("storageData",JSON.stringify(arrStorage));
}
//取本地缓存
function getLocal(name){
var strStorage = localStorage.getItem("storageData");
var arrStorage = JSON.parse(strStorage);
if (arrStorage!=null&&arrStorage.length>0){
var needStr="";
for(var arr=0;arr<arrStorage.length;arr++){
if(name==arrStorage[arr].name){
needStr =arrStorage[arr].val;
return needStr;
}
}
return needStr;
}
}