1 | <!doctype html>
|
2 | <html>
|
3 | <head>
|
4 | <meta charset="utf8" />
|
5 | <title>Simple localForage example</title>
|
6 | </head>
|
7 | <body>
|
8 | <script src="../dist/localforage.js"></script>
|
9 | <script>
|
10 |
|
11 | localforage.setDriver(localforage.LOCALSTORAGE).then(function() {
|
12 | var key = 'STORE_KEY';
|
13 |
|
14 | var value = new Uint8Array(8);
|
15 | value[0] = 65
|
16 |
|
17 | var UNKNOWN_KEY = 'unknown_key';
|
18 |
|
19 | localforage.setItem(key, value, function() {
|
20 | console.log('Saved: ' + value);
|
21 |
|
22 | localforage.getItem(key, function(err, readValue) {
|
23 | console.log('Read: ', readValue);
|
24 | });
|
25 |
|
26 |
|
27 | localforage.getItem(UNKNOWN_KEY, function(err, readValue) {
|
28 | console.log('Result of reading ' + UNKNOWN_KEY, readValue);
|
29 | });
|
30 | });
|
31 | });
|
32 | </script>
|
33 | </body>
|
34 | </html>
|