Cross-browser local storage:
1. localstorage: Only Internet Explorer 8 +, Firefox, chrome, and opera are supported. Browsers with less than Internet Explorer 8 are not supported.
2. browser cookies: a relatively small amount of data storage is supported. Each domain can have a maximum of 20 cookies. Each cookie cannot exceed 4 kb in length. Otherwise, it will be truncated, and some Browsers Do not even support it; at the same time, the cookie has security issues. If the cookie is intercepted, all session information can be obtained.
3. You can embed a hidden flash on the page and then use the flash plug-in dobject of flash. It basically does not have compatibility issues. Only Flash and JS need to be introduced separately, however, this will increase the page load.
4. User Data: it is a storage space specially opened by Microsoft for ie in the system (this supports all IE browsers ), only Windows + IE combinations are supported. (the size of a single file is limited to kb. a domain name can store a total of KB of files. There should be no limit on the number of files. In a restricted site, these two values are 64kb and 640kb respectively .)
To sum up, we can use localstorage + User data as a solution for local storage:
(function (window) { window.localDataStore = { hname: location.hostname ? location.hostname : 'localStatus', isLocalStorage: window.localStorage ? true : false, dataDom: null, initDom: function () { if (!this.dataDom) { try { this.dataDom = document.createElement('input'); this.dataDom.type = 'hidden'; this.dataDom.style.display = "none"; this.dataDom.addBehavior('#default#userData'); document.body.appendChild(this.dataDom); var exDate = new Date(); exDate = exDate.getDate() + 30; this.dataDom.expires = exDate.toUTCString(); } catch (ex) { return false; } } return true; }, set: function (key, value) { if (this.isLocalStorage) { window.localStorage.setItem(key, value); } else { if (this.initDom()) { this.dataDom.load(this.hname); this.dataDom.setAttribute(key, value); this.dataDom.save(this.hname) } } }, get: function (key) { if (this.isLocalStorage) { return window.localStorage.getItem(key); } else { if (this.initDom()) { this.dataDom.load(this.hname); return this.dataDom.getAttribute(key); } } }, remove: function (key) { if (this.isLocalStorage) { localStorage.removeItem(key); } else { if (this.initDom()) { this.dataDom.load(this.hname); this.dataDom.removeAttribute(key); this.dataDom.save(this.hname) } } } }})(window);