Germán Toro del Valle (gtv@tid.es, @gtorodelvalle)
if (localStorage) {
// Storage.
localStorage.key = value;
// Retrieval.
console.log(localStorage.key);
}
db = openDatabase('myDB', '1.0', 'My first Web SQL DB', 8192);
db.transaction(function (tx) {
tx.executeSql("CREATE TABLE IF NOT EXISTS..." // SQL statement.
[], // Parameter array.
function onTXSuccess(transaction, results) { ... },
function onTXError(transaction, error) { ... }
);
});
var request = window.indexedDB.open("MyFirstIndexedDB", 5);
request.onerror = function(event) {
// Do something with request.errorCode!
};
request.onsuccess = function(event) {
// Do something with request.result!
};
window.requestFileSystem(/* type */ window.TEMPORARY, /* size */ 8192,
/* success */ initFS, /* error */ errorHandler);
function initFS(fs){
fs.root.getDirectory('Docs', {create: true}, function(dirEntry) {
console.log(dirEntry.name + 'directory available');
}, errorHandler);
}
function errorHandler(){
console.log('An error occured');
}
// In the following line, you should include the prefixes of
// the implementations you want to support.
window.indexedDB = window.indexedDB || window.mozIndexedDB ||
window.webkitIndexedDB || window.msIndexedDB;