HTML5---localstorage

Source: Internet
Author: User

HTML5 provides a Localstorage object that can save data for long periods of time on the client until the person is cleared.

Localstorage provides several methods: 1, Storage: Localstorage.setitem (key,value) If key is present, update value 2, get: Localstorage.getitem (Key) If key does not exist return null 3, delete: Localstorage.removeitem (key) once deleted, key corresponding data will be deleted all 4, clear all: Localstorage.clear () Sometimes it is too cumbersome to use RemoveItem to delete each other, you can use clear, the result of the execution is to clear all the Localstorage object saved data 5, traverse localstorage stored key.length data total, Example: LocalStorage.length.key (index) Gets key, example: Var key=localstorage.key (index); 6. Store JSON format data json.stringify to convert an object into a JSON-formatted data string, returning the converted string Json.parse (data) to parse the data into objects, returning the parsed object

HTML5---localstorage

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.