1 2 3 4 5 |
if(window.localStorage){ alert('This browser supports localStorage'); }else{ alert('This browser does NOT support localStorage'); } |
1 2 3 4 |
<!DOCTYPE HTML> <html manifest="demo.appcache"> ... </html> |
1 2 3 4 5 6 7 8 9 10 |
CACHE MANIFEST # 2016-07-24 v1.0.0 /theme.css /main.js NETWORK: login.jsp FALLBACK: /html/ /offline.html |
1 2 3 4 |
<mime-mapping> <extension>manifest</extension> <mime-type>text/cache-manifest</mime-type> </mime-mapping> |
1 2 3 |
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024,fn); // openDatabase() 方法对应的五个参数 // 分别为:数据库名称、版本号、描述文本、数据库大小、创建回调 |
1 2 3 4 |
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024); db.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS WIN (id unique, name)'); }); |
1 2 3 4 5 6 |
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024); db.transaction(function (tx) { tx.executeSql('CREATE TABLE IF NOT EXISTS WIN (id unique, name)'); tx.executeSql('INSERT INTO WIN (id, name) VALUES (1, "winty")'); tx.executeSql('INSERT INTO WIN (id, name) VALUES (2, "LuckyWinty")'); }); |
1 2 3 4 5 6 7 8 9 10 11 |
db.transaction(function (tx) { tx.executeSql('SELECT * FROM WIN', [], function (tx, results) { var len = results.rows.length, i; msg = "<p>查询记录条数: " + len + "</p>"; document.querySelector('#status').innerHTML += msg; for (i = 0; i < len; i++){ alert(results.rows.item(i).name ); } }, null); }); |