PropertyEventMethodIndex
$p.local - 5.0_4.4547B.20211124.201933

Provides same function as LocalStorage of HTML5. The LocalStorage can save data in the dedicated area provided by the browser. The size of the data that can be stored depends on the browser settings. Supported for lower IE versions. (See http://www.w3.org/TR/webstorage/#storage.) Similar to the cookie. No expiration date is defined. Depending on the browser, 5MB ~ 10MB data can be stored. 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
$p.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 = $p.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. $p.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. ) $p.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
$p.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
$p.local.removeItem("name"); // Removes 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. $p.local.setItem("name", "WebSquare");