while(off){ if(isleft){ end=base-(off/2); }else{ end=base+(off/2); } sstr=str.slice(0,end); localStorage.clear(); try{ localStorage.setItem('cache',sstr); limit=sstr.length; isleft=0; }catch(e){ isleft=1; } base=end; off=Math.floor(off/2) }
检查localstorage的最大大小