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
I suspect you're trying to do this from a local file (eg 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>
undefined
[object IDBFactory]
For example:
alert(window.indexedDB);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.