nsIDOMStorage2 编辑
The nsIDOMStorage2
interface represents the storage space used for local storage in the DOM. Items stored in local storage may only be accessed by the same origin that created the items in the first place.
A DOM window's local storage object can be retrieved from the window's localStorage
attribute.
dom/public/idl/storage/nsIDOMStorage2.idl
Scriptable Please add a summary to this article. Last changed in Gecko 1.9.1 (Firefox 3.5 / Thunderbird 3.0 / SeaMonkey 2.0)Inherits from: nsISupports
Method overview
void clear(); |
DOMString getItem(in DOMString key); |
DOMString key(in unsigned long index); |
void removeItem(in DOMString key); |
void setItem(in DOMString key, in DOMString data); |
Attributes
Attribute | Type | Description |
length | unsigned long | The number of keys stored in local storage. |
Methods
clear()
Clears the contents of this storage context; this removes all values bound to the domain or origin.
void clear();
Parameters
None.
getItem()
Returns from local storage the data corresponding to the specified key.
DOMString getItem( in DOMString key );
Parameters
key
- The key for which data should be returned.
Return value
A string containing the data corresponding to the specified key, or null
if no data exists for the given key.
key()
Returns the key for the item stored at the specified index in the data store.
DOMString key( in unsigned long index );
Parameters
index
- The index for which the corresponding key should be returned.
Return value
A string containing the requested key.
Exceptions thrown
INDEX_SIZE_ERR
- There is no key at the specified index.
removeItem()
Given a key, removes the corresponding entry from local storage.
void removeItem( in DOMString key );
Parameters
key
- The key for which data should be removed from storage.
setItem()
Sets the value corresponding to a given key. If the key does not already exist, a new key is added, associated with the specified value. If the key already exists, the existing value is replaced with the specified value.
void setItem( in DOMString key, in DOMString data );
Parameters
key
- The key for which data should be set.
data
- The data to associate with the specified
key
.
See also
- DOM Storage
- Structured client-side storage (HTML 5 specification)
nsIDOMStorageItem
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论