HTMLStorage object

Represents the list of key/value pairs that have been assigned to a single storage area.

HTML5 A vocabulary and associated APIs for HTML and XHTMLInternet Explorer 8

Members

The HTMLStorage object has these types of members:

Methods

The HTMLStorage object has these methods.

MethodDescription
clear

Removes all key/value pairs from the Web Storage area.

getItem

Retrieves the current value associated with the Web Storage key.

key

Retrieves the key at the specified index in the collection.

removeItem

Deletes a key/value pair from the Web Storage collection.

setItem

Sets a key/value pair.

 

Properties

The HTMLStorage object has these properties.

PropertyDescription

constructor

Returns a reference to the constructor of an object.

length

Retrieves the length of the key/value list.

remainingSpace

Retrieves the remaining memory space, in bytes, for the storage object.

 

Standards information

Remarks

Each Storage object provides access to a list of key/value pairs, which are sometimes called items. Keys are strings, and any string (including the empty string) is a valid key. Items contain values (which are also strings) and associated metadata.

Each Storage object is associated with a list of key/value pairs when it is created. Multiple Storage objects, such as two instances of localStorage, can be associated with the same list of key/value pairs simultaneously.

Examples

Key names are exposed as properties on this object. For example, the following statements are equivalent:


sessionStorage.setItem('myKey', '...');
					
sessionStorage['myKey'] = '...'; 
	
sessionStorage.myKey = '...'; 

See also

localStorage

 

 

Show:
© 2014 Microsoft