mirror of
https://github.com/localForage/localForage.git
synced 2026-01-25 14:44:26 +00:00
29 lines
753 B
HTML
29 lines
753 B
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf8" />
|
|
<title>Simple localForage example</title>
|
|
</head>
|
|
<body>
|
|
<script src="../dist/localForage.js"></script>
|
|
<script>
|
|
var key = 'STORE_KEY';
|
|
var value = 'What we save offline';
|
|
var UNKNOWN_KEY = 'unknown_key';
|
|
|
|
localForage.setItem(key, value, function() {
|
|
console.log('Saved: ' + value);
|
|
|
|
localForage.getItem(key, function(readValue) {
|
|
console.log('Read: ', readValue);
|
|
});
|
|
});
|
|
|
|
// Since this key hasn't been set yet, we'll get a null value
|
|
localForage.getItem(UNKNOWN_KEY, function(readValue) {
|
|
console.log('Result of reading ' + UNKNOWN_KEY, readValue);
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|