Skip to content

Instantly share code, notes, and snippets.

@chengmu
Created January 30, 2014 15:48
Show Gist options
  • Save chengmu/8711499 to your computer and use it in GitHub Desktop.
Save chengmu/8711499 to your computer and use it in GitHub Desktop.
try {
if (!window.openDatabase) {
alert('not supported');
} else {
var shortName = 'mydatabase';
var version = '1.0';
var displayName = 'My Important Database';
var maxSize = 65536; // in bytes
var db = openDatabase(shortName, version, displayName, maxSize);
// You should have a database instance in db.
}
} catch(e) {
// Error handling code goes here.
if (e == 2) {
// Version number mismatch.
alert("Invalid database version.");
} else {
alert("Unknown error "+e+".");
}
return;
}
alert("Database is: "+db);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment