IndexedDBShim.js错误:JavaScript运行时错误:在严格模式下不允许分配只读属性

IndexedDBShim.js error : JavaScript runtime error: Assignment to read-only properties is not allowed in strict mode

本文关键字:模式 不允许 分配 只读属性 错误 js JavaScript 运行时错误 IndexedDBShim      更新时间:2023-09-26

我正在试用IndexedDBjquery API,因为IndexedDB与safari/ipad不兼容。我刚开始使用它,但在只运行HTML时出现了这个错误,我无法使用文件中的任何内容。我引用的文件是IndexedDBShim

我的html看起来像

    <!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script src="JavaScript1.js" type="text/javascript"></script>
    <script src="/Scripts/IndexedDBShim.js" type="text/javascript"></script>
    <script src="/Scripts/IndexedDBShim.min.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.indexeddb.js" type="text/javascript"></script>
    <script src="/Scripts/jquery.indexeddb.min.js" type="text/javascript"></script>
</head>
<body>
    <button onclick="test()">CREATE DATABASE</button>
</body>
</html>

Test()函数中没有任何内容。我得到的错误是:0x800a13b5-JavaScript运行时错误:在严格模式下不允许分配只读属性在第1653行的window.indexedDB=window.indexed DB||window.webkitIndexedDB||windows.mozIndexedDB2||window.oIndexedDB ||window.msIndexedDB;

我用错这个了吗?

感谢

您不再需要使用以下行:

window.indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.oIndexedDB || window.msIndexedDB;

在所有浏览器中,关键字indexedDB现在已成为标准http://caniuse.com/#search=IndexedDB.