Provides a universal local storage to support cross-browsing.
WebSquare.localStorage.length Gets the size of the entire (key, value) pair data in the local storage.
WebSquare.localStorage.key Gets the key value of the corresponding index.
WebSquare.localStorage.setItem Sets (key, value) pair data in the local storage.
WebSquare.localStorage.getItem Gets the key value saved in the local storage.
WebSquare.localStorage.removeItem Removes the item of the corresponding key.
WebSquare.localStorage.clear Clears the entire data of the local storage.
WebSquare.localStorage.getAllItem Returns all data saved in the local storage as an object.
See http://www.w3.org/TR/webstorage/#storage.
Type
- engine
Property Summary
Event Summary
Method Summary
- clear( )
- Deletes the entire data saved in the local storage.
- getAllItem( )
- Returns all data saved in the local storage as (key, value) objects.
- getItem( key )
- Gets the key value.
- key( index )
- Gets the key of the specified index.
- removeItem( key )
- Removes the item of the corresponding key.
- setItem( key , val )
- Sets a (key, value) pair in the local storage.
Property Detail
Event Detail
Method Detail
- clear( )
-
Deletes the entire data saved in the local storage.
See http://www.w3.org/TR/webstorage/#storage : clear.SampleWebSquare.localStorage.clear(); // Deletes the entire data saved in the WebSquare.localStorage component. - getAllItem( )
-
Returns all data saved in the local storage as (key, value) objects.
Return type description Object Entire data of the current component object Samplevar data = WebSquare.localStorage.getAllItem(); // Gets the entire data saved in the WebSquare.localStorage component. - getItem( key )
-
Gets the key value.
See http://www.w3.org/TR/webstorage/#storage : getItem.Parameter name type required description key String Y Key of the item Return type description String The value matching with the key. In case no value matches with the key, null data will be returned. - key( index )
-
Gets the key of the specified index.
See http://www.w3.org/TR/webstorage/#storage : key.Parameter name type required description index Number Y Storage index (Similar to the index in the array) Return type description String The value matching with the index. In case no value matches with the index, null data will be returned. - removeItem( key )
-
Removes the item of the corresponding key.
See http://www.w3.org/TR/webstorage/#storage : removeItem.
Changes in the local storage will be immediately applied.
Call clear() to delete the entire data.Parameter name type required description key String Y Key of the item to delete SampleWebSquare.localStorage.removeItem("key1"); // Deletes the item of key1. - setItem( key , val )
-
Sets a (key, value) pair in the local storage.
See http://www.w3.org/TR/webstorage/#storage : setItem.
Changes in the local storage will be immediately applied.Parameter name type required description key String Y Item key val String Y Item value SampleWebSquare.localStorage.setItem("age", "25"); // Saves "25" for the key "age". Using WebSquare.localStorage.getItem("age") will return "25".