Home  >  Article  >  Web Front-end  >  Detailed explanation of H5 local storage instance

Detailed explanation of H5 local storage instance

零下一度
零下一度Original
2017-07-24 11:11:111605browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn