--- title: IDBDatabase.name slug: Web/API/IDBDatabase/name tags: - Database - IDBDatabase - IndexedDB - Property - Storage - name translation_of: Web/API/IDBDatabase/name ---
{{ APIRef("IDBDatabase") }}
{{ domxref("DOMString")}}です。IDBDatabaseインターフェイスの
nameプロパティは、接続しているデータベース名を含む
db.name
接続しているデータベース名を含む
{{ domxref("DOMString")}}。
この例は接続しているデータベースと、DBのversionとnameプロパティを持つ{{domxref("IDBDatabase")}} オブジェクトの結果、そしてログを表示します。完全な例は、To-do Notifications app (view example live)を見てください。
// Let us open our database var DBOpenRequest = window.indexedDB.open("toDoList", 4); // these two event handlers act on the database being opened successfully, or not DBOpenRequest.onerror = function(event) { note.innerHTML += '<li>Error loading database.</li>'; }; DBOpenRequest.onsuccess = function(event) { note.innerHTML += '<li>Database initialised.</li>'; // store the result of opening the database in the db variable. This is used a lot below db = DBOpenRequest.result; // This line will log the name of the database, which should be "toDoList" console.log(db.name); };
Specification | Status | Comment |
---|---|---|
{{SpecName('IndexedDB', '#widl-IDBDatabase-name', 'name')}} | {{Spec2('IndexedDB')}} |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic support | 23{{property_prefix("webkit")}} 24 |
10 {{property_prefix("moz")}} {{CompatGeckoDesktop("16.0")}} |
10, partial | 15 | 7.1 |
Feature | Android | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Basic support | 4.4 | {{CompatGeckoMobile("22.0")}} | 1.0.1 | 10 | 22 | {{CompatNo}} |