PropertyEventMethodIndex
$w.local - 5.0_2.3750B.20190805.154938

Functions same as the LocalStorage of HTML5, and supported by lower IE versions. (For more information, see http://www.w3.org/TR/webstorage/#storage.)
The LocalStorage can save data in the area provided by the browser. The size of the data that can be stored depends on the browser settings.
Similar to the cookie. However, there is no expiration and a larger amount of data can be stored. In most cases, 5MB~10MB data can be stored depending on the browser. It is recommended to save not more than 5MB to support multi-browsing.

Type

engine

Property Summary

Event Summary

Method Summary

clear( )
Deletes the data saved in the localStorage for the same domain.
getAllItem( )
Returns all data saved in the localStorage for the same data as a key/value object.
getItem( keyName )
Returns the keyName from the LocalStorage.
key( index )
Gets the key of the corresponding index.
length( )
Number of (key, value) pair data in the localStorage.
removeItem( key )
Removes the data (item) of the corresponding keyName.
setItem( keyName , value )
Saves the key/value data in the localStorage.

Property Detail

Event Detail

Method Detail

clear( )
Deletes the data saved in the localStorage for the same domain.
Sample
$w.local.clear();
getAllItem( )
Returns all data saved in the localStorage for the same domain as a (key, value) pair object.
Return
typedescription
JSONJSON object containing key/value data
Sample
var tmpData = $w.local.getAllItem(); // (Return Example) { name:"WebSquare" , add:"Seoul" }
getItem( keyName )
Returns the value of the specified keyName from the LocalStorage.
Parameter
nametyperequireddescription
keyNameStringYSaved key vavlue.
Return
typedescription
StringIf there is any data matching with the keyName, the value will be returned. Otherwise, null will be returned.
Sample
// "WebSquare" is saved with the key of name. $w.local.getItem("name"); (Return Example) "WebSquare"
key( index )
Gets the key of the specified index. The index of the saved key depends on the browser. In other words, the index may differ in each browser.
Parameter
nametyperequireddescription
indexNumberYIndex of the saved key.
Return
typedescription
StringReturns the key of the specified index. Otherwise, null will be returned.
Sample
// In Chrome, the index of the last saved value is 0, while in IE, the index of the first save value is 0. (Compared to November 2014. ) $w.local.key(0); (Return Example) "name"
length( )
Number of the (key, value) pair data in the local storage.
Return
typedescription
NumberNumber of (key/value) data saved in the localStorage.
Sample
$w.local.length (Return Example) 2
removeItem( key )
Removes the data (item) of the corresponding keyName.
Call clear() to delete all data.
Parameter
nametyperequireddescription
keyStringYKey of the data (item) to delete
Sample
$w.local.removeItem("name"); // Delete the name item.
setItem( keyName , value )
Saves key/value data in the localStorage.
Parameter
nametyperequireddescription
keyNameStringYKey to save
valueStringYValue to save
Sample
// Save Websquare value with name key. $w.local.setItem("name", "WebSquare");