let db;
// Let us open our database
const DBOpenRequest = window.indexedDB.open("toDoList", 4);
// Handle the case where there is an error opening the database
DBOpenRequest.addEventListener("error", (event) => {
note.appendChild(document.createElement("li")).textContent =
"Error loading database.";
});
// Handle the case where the database opens successfully
DBOpenRequest.addEventListener("success", (event) => {
note.appendChild(document.createElement("li")).textContent =
"Database initialized.";
// store the result of opening the database.
db = DBOpenRequest.result;
});IDBRequest / notebook
IDBRequest
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.