这是 W3C 示例为离线 Web 存储提供的代码:http: //www.w3.org/TR/offline-webapps/
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" charset="utf-8">
function renderNote(row) {
console.log(row);
}
function reportError(source, message) {
console.log("err");
}
function renderNotes() {
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS Notes(title TEXT, body TEXT)',
[]);
tx.executeSql('SELECT * FROM Notes', [], function(tx, rs) {
for(var i = 0; i < rs.rows.length; i++) {
renderNote(rs.rows[i]);
}
});
});
}
function insertNote(title, text) {
db.transaction(function(tx) {
tx.executeSql('INSERT INTO Notes VALUES(?, ?)', [ title, text ],
function(tx, rs) {
// …
},
function(tx, error) {
reportError('sql', error.message);
});
});
}
</script>
</head>
<body>
</body>
</html>
根本没有控制台日志输出。有什么事?