2
我有一個使用WebSQL構建的Web站點用於脫機存儲。我使用Web Worker在後臺運行一些數據庫查詢。WebSQL在Chrome內部的Web Worker中不起作用39
在最新版本的Chrome 39.0.2171.95中,它不再有效,它似乎沒有加載WebSQL API。我得到的錯誤是:
Uncaught ReferenceError: openDatabase is not defined
的index.html
<html>
<head>
<script>
//opening the database works here
var db = openDatabase('db','1.0','db',10);
console.log(db);
//opening the database fails in web worker
var syncWorker = new Worker("worker.js");
syncWorker.postMessage(0);
</script>
</head>
<body></body>
</html>
worker.js
onmessage = function(evt) {
var db = openDatabase('db','1.0','db',10); //produces Uncaught ReferenceError: openDatabase is not defined
console.log(db);
};
但是,如果網絡工作者是動態加載而不是從文件,它的工作原理:
http://jsbin.com/warokilodi/12/edit?html,js,console,output
比動態加載的工人有一種解決方法/修復等?