You need to take advantage of the HTML5 localstorage in your project. However, when using this attribute, it is found that the target cannot be reached. After continuous inspection and elimination, the final reason is found:
The browsers used in the project support Localstorage, but they are not available, and the reason is unknown (presumably the configuration of the browser's environment variables may need to be used directly, but I am powerless to do so).
Finally, through the Internet query, found that can use cookies to achieve the function of localstorage (of course, the data is stored for a limited time), the code is as follows:
<script type="Text/javascript">//Create LocalStorage1varLocalstorage1class =function () { This. options ={Expires: -* -*3600, }} Localstorage1class.prototype= { //initial manifestation. Add an Expiration timeinit:function () {varDate =NewDate (); Date.settime (Date.gettime ()+ -* -*3600); This. SetItem ('Expires', date.togmtstring ()); }, //intrinsic function parameter description (key) Check if key existsfinditem:function (key) {var BOOL=document.cookie.indexOf (key); if(BOOL<0 ){ return true; }Else{ return false; } }, //get element value get element value return NULL if not presentgetitem:function (key) {vari = This. FindItem (key); if(!i) { varArray = Document.cookie.split (';') for(varj=0; j<array.length;j++){ varArraysplit =Array[j]; if(Arraysplit.indexof (key) >-1){ varGetValue = Array[j].split ('='); //Remove getvalue[0] trim to delete both spacesgetvalue[0] = getvalue[0].replace (/^\s\s*/,"'). Replace (/\s\s*$/,"') if(getvalue[0]==key) { returngetvalue[1]; }Else{ return 'NULL'; } } } } }, //re-setting elementssetitem:function (key,value) {vari = This. FindItem (key) Document.cookie=key+'='+value; }, //Clear All cookie parametersremove:function () {varArray = Document.cookie.split (';') for(varCL =0; cl<array.length;cl++){ varDate =NewDate (); Date.settime (Date.gettime ()- -); Document.cookie=ARRAY[CL] +"=a; expires="+date.togmtstring (); } }} varLocalStorage1 =NewLocalstorage1class (); Localstorage1.init ();</script>
Reprint: http://blog.csdn.net/xiaosong521/article/details/7733424
Using cookies to implement Localstorage functions