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 type description JSON JSON object containing key/value data Samplevar tmpData = $p.local.getAllItem(); // (Return Example) { name:"WebSquare" , add:"Seoul" } - getItem( keyName )
-
Returns the value of the specified keyName from the LocalStorage.
Parameter name type required description keyName String Y Saved key vavlue. Return type description String If 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 name type required description index Number Y Index of the saved key. Return type description String Returns 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 type description Number Number 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 name type required description key String Y Key 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 name type required description keyName String Y Key to save value String Y Value to save Sample// Save Websquare value with name key. $p.local.setItem("name", "WebSquare");