我在使用indexedDB方面有一个非常基本的失败。运行在当前的Firefox (56.0,64位)中,但我已经看到这个问题有一段时间了。
以下非常简单的HTML/Javascript演示了这个问题:
<!DOCTYPE html>
<html>
<head>
<title>indexedDB simple test</title>
<script src="/fb/jquery-2.2.4.min.js"></script>
</head>
<body>
<div id="wrapper"></div>
<script>
try {
if ('indexedDB' in window) {
$('#wrapper').append('Has native indexedDB<br />');
} else {
indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
IDBKeyRange = window.IDBKeyRange || window.webkitIDBKeyRange || window.msIDBKeyRange;
$('#wrapper').append('Has indexedDB, but not native<br />');
}
if (indexedDB) {
var ver = 1;
if ( ! 'open' in indexedDB ) {
$('#wrapper').append('indexedDB.open doesn\'t exist.<br />');
}
if ( typeof indexedDB.open != 'function' ) {
$('#wrapper').append('indexedDB.open is not a function.<br />');
}
try {
var request = indexedDB.open("foo", ver);
} catch (ex) {
$('#wrapper').append('indexedDB.open threw error.<br />');
}
}
} catch (ex) {
}
</script>
</body>indexedDB显示为本地函数;indexedDB.open显示为现有函数;但当调用它时,网络控制台在indexed_db_simple_test.html:28:30上显示“UnknownError”。我不知道可能出了什么问题。
发布于 2017-10-14 21:52:36
我已经处理这个问题好几天了。在我们的例子中,我们发现问题在于用户使用Firefox,似乎当配置文件因升级而损坏时,indexedDB就无法正常工作。我们发现的修复方法是使用这个命令创建一个新的配置文件:
$ /Applications/Firefox.app/Contents/MacOS/firefox-bin -P
如果这确实解决了您的问题,那么您可以看到这里提到的火狐问题:bug.cgi?id=1246615。
有关该配置文件命令的更多信息,请参见docs:https://support.mozilla.org/en-US/kb/profile-manager-create-and-remove-firefox-profiles
我们目前的解决方案不仅仅是让应用程序爆炸,我们的解决方案是进行功能检查,基本上如下所示:
var DBOpenRequest = window.indexedDB.open('someDb');
DBOpenRequest.onerror = function(event) {
window.location.href = '/unsupported_browser.html';
};我们还要求用户修复他们的配置文件,以便能够使用我们的应用程序(它依赖于indexedDB来工作)。
我希望这能帮到你!
https://stackoverflow.com/questions/46553473
复制相似问题