Q:

How to get indexedDB to work in IE11?

I want to use indexedDB in my IE11, but it seems to be undefined. This is the code:
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>

    <script>
        window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;

        window.IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
        window.IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange

        if (IDBTransaction) {
            window.IDBTransaction.READ_WRITE = window.IDBTransaction.READ_WRITE || 'readwrite';
            window.IDBTransaction.READ_ONLY = window.IDBTransaction.READ_ONLY || 'readonly';
        }
        if (!window.indexedDB) {
            window.alert("Your browser doesn't support a stable version of IndexedDB.")
        }
        alert(document.documentMode);
        alert(document.compatMode);
    </script>
</head>

<body>
 The content of the document......
</body>

</html> 

it alerts:
Your browser doesn't support a stable version of IndexedDB.
11
CSS1Compat

Does anyone know what's wrong?
Thanks

A:

I suspect you're trying to do this from a local file (e.g. c:\test.html) rather than an HTTP resource. IE probably restricts access to the API from file (or non-HTTP) origins.
If I save your content locally to a file it alerts as you noted in IE. If I serve the content via a server, it works correctly.
A simpler example:
<script>
alert(window.indexedDB);
</script>

Local file: undefined
Served: [object IDBFactory]

For example:

alert(window.indexedDB);

