這是由W3C例如,對於離線Web存儲提供的代碼:http://www.w3.org/TR/offline-webapps/HTML5離線存儲不工作
<!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>
沒有控制檯日誌輸出的。有什麼事?
webstorage不是webSQL的替代品IndexedDB是。 localStore是一個使用非常有限的鍵值數據存儲區。現在IndexedDB比webSQL更不支持,總體來說很糟糕,試着在IndexedDB中進行左連接,你就會明白我的意思了。 – Astronaut 2013-03-27 00:49:34