简体   繁体   中英

Internet Explorer Local Storage

I have a application which works great on all browsers but IE. I am using the local database provided with HTML5. I need to store 3 attributes for the users of the application. I know in IE I can't use the database approach and I was thinking of using 3 arrays stored in local storage, one array for each attribute. Is there a better (and easier) way of doing this?

Thanks

For example, I want to store 1) destination 2) where they are from 3) date So I was thinking I will store an array for destinations, an array fro from locations and an array for dates. Then using some id I can index the arrays and get the corresponding information.

If you need local storage, then you need local storage! Based on the information you describe, I think it's probably too heavy to use in a session cookie.

Check out the docs . Be aware that only IE8+ supports this, so if you need to support other versions - you'll need to do some extra work.

I would personally enable localStorage where possible, then fall back to a round-trip to the server if the browser doesn't support it (and the data is definitely too much for cookies).

Update RE Polyfills

Keep in mind that the polyfills suggested by Rafael will fall back to cookies if the browser doesn't support localStorage etc. Be sure to test with a good spread of data, and keep in mind that it will be sending all that data with each request (which has it's own ramifications).

For IE, you can use a polyfill to simulate a native localStorage: https://github.com/Modernizr/Modernizr/wiki/HTML5-Cross-browser-Polyfills

LocalStorage uses a key:value system. But you can save more than one data in one key, using JSON.Stringify & JSON.parse.

localStorage in IE does not work with this url: file:///P:/Dropbox/abc_web/ingrid8/ingrid.htm#car..

through network if it works: file://pedrojelp/p/Dropbox/abc_web/ingrid8/ingrid.htm#car..

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM