如何使indexedDB在IE11中工作? [英] How to get indexedDB to work in IE11?
本文介绍了如何使indexedDB在IE11中工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在IE11中使用indexedDB,但似乎未定义.这是代码:
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>
它会发出警报:
Your browser doesn't support a stable version of IndexedDB.
11
CSS1Compat
有人知道怎么了吗?
谢谢
推荐答案
我怀疑您正在尝试通过本地文件(例如c:\test.html
)而不是HTTP资源来执行此操作. IE可能会限制从文件(或非HTTP)来源访问API.
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.
如果我将您的内容保存到本地文件中,则会在IE中提醒您.如果我通过服务器提供内容,则它可以正常工作.
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.
一个简单的例子:
<script>
alert(window.indexedDB);
</script>
- 本地文件:
undefined
- 投放:
[object IDBFactory]
- Local file:
undefined
- Served:
[object IDBFactory]
例如:
alert(window.indexedDB);
这篇关于如何使indexedDB在IE11中工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文