Returns the current value associated with the given key.
Method of apis/web-storage/Storageapis/web-storage/Storage
Syntaxvar = object.getItem(key);
Parameters key
The name of the key (a valid UTF-16 string, including the empty string).
Return ValueReturns an object of type StringString
ExamplesThis example creates a new localStorage item (a timestamp) and sets it with a unique key, then executes a function, then retrieves the timestamp by its key and reports it.
window.localStorage.setItem('timestamp', (new Date()).getTime());
doSomethingElse();
startTime = window.localStorage.getItem('timestamp');
alert("The doSomethingElse function was called at: " + startTime);
Notes
Any valid UTF-16 string, including the empty string, is a valid key name. If the specified key does not exist in the list associated with the object, then this method returns null. Attempts to read or write a secured item from script running in the context of an unsecured URL are not permitted.
Related specificationsMicrosoft Developer Network: Windows Internet Explorer API reference Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4