Home >Web Front-end >H5 Tutorial >Detailed explanation of H5 local storage instance
They can store: Arrays json data pictures scripts style files;
Two client storage options:
1.localStorage data storage without time limit ()
Methods are: .localStrage.getItem();localStrage.setItem();removeItem();localStrage.key() starts from 0;.localStrage,clear();
To use it to store pictures, you need to pass A layer of canvas, the same size as the picture, is rendered into the canvas, and the toDateURL() method of the canvas is used to store it locally. Use try()catch(e){} to obtain the cached data locally and render it.
Notes: a. Before use, please pay attention to determine whether the browser supports it.
b. When writing data, exception handling is required to avoid exceeding the capacity and reporting errors
c. Avoid storing sensitive information in localStrage
d. Uniqueness of key
Usage restrictions: a. Storage update policy, expiration control
b. Storage data cannot be shared between subdomain names
c. How to store after exceeding the storage size,
d. How to get () on the server side
2.sessionStorage session data storage
The above is the detailed content of Detailed explanation of H5 local storage instance. For more information, please follow other related articles on the PHP Chinese website!