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 use RemoveItem to remove too much trouble, you can use clear, the result of the execution is to clear all Localstorage objects saved data 5, Traverse localstorage stored key. length data Total, example: LocalStorage.length.key (index) Get 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 Note: Localstorage data is not shared across browsers, a browser can only read the data of their respective browsers, storage space 5M.
Use of Localstorage