HTML5 localStorage
what could be the real practical use of HT开发者_如何学JAVAML5 localStorage?
Caching data from an online web application so that the application can be used in offline scenarios (albeit with only the cached data).
Persisting user specific UI state like what page a user is on, scroll position, etc. (if you really wanted to do that kind of thing).
Persisting transient data in a web application (i.e. A user partially fills out a form and then navigates to another page in your application then decides to come back. You can allow them to pick up where they left off).
Allow a user to enter data in your app while offline and then send the data to the server in the background next time the user is online.
I use it for rescuing/autosaving form content.
For example if a user accidentally closes the browser or navigates away from the page data loss can be avoided.
Check out my plugin: https://github.com/simmo/JQuery-Rescue
I used localStorage to create a Plugin that does the following thing
1.Stores background mode(image mode or color mode).
2.Stores image as base64.
3.Stores image and color options(custom,choose,random,auto change).
4.Stores Settings.
Like this u can use LocalStorage for storing data and improve performance But u can store in upto 5MB data only.
I use it to save local site theme settings that have no business being set (and broadcast) as cookies. I wrote a tool to help me, called localDataStorage. It transparently sets/gets Arrays, Booleans, Dates, Floats, Integers, Strings and Objects. It provides lightweight data obfuscation (for security) and intelligently compresses strings. The utility lets you query by key (name) or (key) value or data type, checks for duplicate values, and supports the notion of write-protected keys. Note: I am the author of the utility.
精彩评论