H5-localstorage, Sessionstorage use method

Source: Internet
Author: User
Tags sessionstorage
HTML5 provides a new way to store data on the client side and is supported by other browsers except IE7 and the following are not supported.
Brief description: Localstorage-no time limit data storage, as long as the user does not manually purge will remain in the local, sessionstorage-session session of the data storage, turn off the browser is cleared; Localstorage and Sessionstorage all have the following methods:
1. Storing DataLocalstorage.setitem ("Key", "value");//key is the stored data name, similar to the name in the Var name= "Shire". or localstorage.key= "value";//an Object-like action method
2. Delete a single specified dataLocalstorage.removeitem ("key");
3. Delete all dataLocalstorage.clear (); If you want to change a stored data, use the SetItem to overwrite the data that you want to change. 4. Get locally stored data-checkvar value=localstorage.getitem ("key");//value is the value that is saved
5.key () and length implementation traversal of stored dataRefer to the following demo for specific use:
<! DOCTYPE html>  


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.