1 | <!DOCTYPE HTML>
|
2 | <html>
|
3 | <head>
|
4 | <script type="text/javascript">
|
5 | var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
|
6 | var msg;
|
7 | db.transaction(function (tx) {
|
8 | tx.executeSql('CREATE TABLE IF NOT EXISTS LOGSSS (id unique, log)');
|
9 | tx.executeSql('INSERT INTO LOGSSS (id, log) VALUES (1, "foobar")');
|
10 | tx.executeSql('INSERT INTO LOGSSS (id, log) VALUES (2, ?)', [(new Blob([94864]))]);
|
11 | msg = '<p>Log message created and row inserted.</p>';
|
12 | document.querySelector('#status').innerHTML = msg;
|
13 | });
|
14 |
|
15 | db.transaction(function (tx) {
|
16 | tx.executeSql('SELECT * FROM LOGSSS', [], function (tx, results) {
|
17 | var len = results.rows.length, i;
|
18 | msg = "<p>Found rows: " + len + "</p>";
|
19 | document.querySelector('#status').innerHTML += msg;
|
20 | for (i = 0; i < len; i++){
|
21 | msg = "<p><b>" + results.rows.item(i).log + "</b></p>";
|
22 | document.querySelector('#status').innerHTML += msg;
|
23 | console.log(msg);
|
24 | }
|
25 | }, null);
|
26 | });
|
27 | </script>
|
28 | </head>
|
29 | <body>
|
30 | <div id="status" name="status">Status Message</div>
|
31 | </body>
|
32 | </html>
|