// 存储到localstorage 半小时 function setlocalStorage(year,range,data){ var date = new Date().getTime() var key = 'data' + year + range var storage = window.localStorage; var obj = {key:data,'time':date} localStorage.setItem(key, JSON.stringify(obj)) } // 判断是否过期半小时 function judgelocalStorage(year,range){ var date = new Date().getTime() var key = 'data' + year + range var storage = window.localStorage; if(JSON.parse(localStorage.getItem(key))){ if(date - JSON.parse(localStorage.getItem(key)).time > 1800000){ storage.removeItem(key) return null } else { return JSON.parse(storage.getItem(key)).key } } else { return null }