判断浏览器是否支持localStorge
判断浏览器是否为无痕模式
简单的json 编码
//存储localStorge function setLocalStorage(key,obj){ if(!navigator.cookieEnabled||typeof window.localStorage == 'undefined'){ return false; } localStorage.setItem(key, JSON.stringify(obj)); return true; } //读取localStorge function getLocalStorage(key){ if(!navigator.cookieEnabled||typeof window.localStorage == 'undefined'){ return false; } var str=localStorage.getItem(key); if(!str){ return false; } return JSON.parse(str); }