Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript HTML5资源存储_Javascript_Html_Iframe - Fatal编程技术网

Javascript HTML5资源存储

Javascript HTML5资源存储,javascript,html,iframe,Javascript,Html,Iframe,我正在制作HTML5游戏。我使用indexedDB来存储图像(大约50mb)。它工作得很好。但我想把我的游戏添加到游戏网站。游戏网站用于游戏iframe。这在Chrome中非常有效。但是firefox有一个错误 TypeError: indexedDB is undefined var request = indexedDB.open(dbName,BDversion); 因为iframe中的window.mozIndexedDB为null 我在mozila页面上找到了以下信息: 需要注意

我正在制作HTML5游戏。我使用indexedDB来存储图像(大约50mb)。它工作得很好。但我想把我的游戏添加到游戏网站。游戏网站用于游戏iframe。这在Chrome中非常有效。但是firefox有一个错误

TypeError: indexedDB is undefined
var request = indexedDB.open(dbName,BDversion);  
因为iframe中的window.mozIndexedDB为null

我在mozila页面上找到了以下信息:

需要注意的是,IndexedDB不适用于加载的内容 从另一个站点(无论是
还是
)进入一个框架。这是一个 安全和隐私措施,可被视为类似 阻止第三方Cookie。有关更多详细信息,请参阅错误595307

你知道怎么解决吗? P.S.Web SQL数据库-似乎很快将不受支持

我的代码:

 function RequestIm() {
                $.ajax({
                    type: "POST",
                    url: BattleNs.addUrl +"/Battle/GetPicture",
                    data: "{ \"id\": \"111\",\"PictureID\":" + "\"" + ID + "\"" + "}",
                    contentType: "application/json; charset=utf-8",
                    async: false,
                    success: function (Picture) {
                        returnpic = Picture;
                        // alert(UnitsInfoMass);
                        return returnpic;
                    }
                });

                Data = returnpic;
                var tempdata = { UniID: ID, Data: Data, DataVersion: DataVersion };
                var request = objectStore.put(tempdata);
                request.onsuccess = function (event) {
                    CountOfDBIterrations[Numer].ID = ID;
                    CountOfDBIterrations[Numer].Image.src = returnpic;
                    CountOfDBIterrations[Numer].Image.onload = function (e) {
                        CountOfDBIterrations[Numer].Loaded = true;
                         BattleNs.loadingCount++;
                          BattleNs.loadingCountChange();
                    };
                };

IndexedDB不是存储图像的最佳场所。请考虑将游戏更改为Web应用程序。您可以将图像和其他资产包含在清单中,浏览器会将其下载到本地PC。您的应用程序可以直接访问它们,而无需从DB中解包


更多信息

Hm,看起来不错。但是我用ajax加载了我的图像。我没有将它们附加到dom中。你知道在这种情况下该怎么办吗?我检查了dipper,发现indexedDb和清单缓存在sqlite文件中存储数据。所以看起来差别不大