Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML DOM indexedDB open() Method

Improve Article
Save Article
  • Last Updated : 31 Jul, 2020
Improve Article
Save Article

The open() method of the indexedDB interface requests opening a connection to a database. This method returns an IDBOpenDBRequest object immediately and performs the open operation asynchronously.


var IDBOpenDBRequest =;
// Or
var IDBOpenDBRequest =, version);

Parameters:  This method accepts two parameters as mentioned above and described below:

  • name: The name of the database to be opened.
  • version (Optional): The version to open the database with.

Return value: This method returns a IDBOpenDBRequest object.

Example: In this example, we will open a database named “toDoList” using this method.


<!DOCTYPE html>
    <title>indexedDB open() method</title>
<body style="text-align: center;">
    <h1 style="color: green;">
        HTML | indexedDB open() method
    <button onclick="Geeks()">
        Click Here
    <p id="a"></p>
    var a = document.getElementById("a");
    function Geeks() {
        window.indexedDB = window.indexedDB || 
                           window.mozIndexedDB ||
                           window.webkitIndexedDB ||
        window.IDBTransaction = window.IDBTransaction || 
                                window.webkitIDBTransaction || 
        window.IDBKeyRange = window.IDBKeyRange || 
                             window.webkitIDBKeyRange ||
        var DBOpen ="toDoList", 4);
        DBOpen.onerror = function (event) {
            a.innerHTML += "<li>Error loading database.</li>";
        DBOpen.onsuccess = function (event) {
            a.innerHTML += "<li>Database initialised.</li>";


Before Button Click:

After Button Click: In the console, IDBOpenDBRequest object can be seen along with database “toDoList” in databases array

Supported Browsers: 

  • Google Chrome
  • Edge
  • Firefox
  • Safari
  • Opera

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!