PropertyEventMethodIndex
WebSquare.localStorage - 5.0_4.4547B.20211124.201933

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.
Sample
WebSquare.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
typedescription
ObjectEntire data of the current component object
Sample
var 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
nametyperequireddescription
keyStringYKey of the item
Return
typedescription
StringThe 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
nametyperequireddescription
indexNumberYStorage index (Similar to the index in the array)
Return
typedescription
StringThe 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
nametyperequireddescription
keyStringYKey of the item to delete
Sample
WebSquare.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
nametyperequireddescription
keyStringYItem key
valStringYItem value
Sample
WebSquare.localStorage.setItem("age", "25"); // Saves "25" for the key "age". Using WebSquare.localStorage.getItem("age") will return "25".