Chrome 39中,WebSQL无法在Web Worker内运行

3
我有一个使用WebSQL进行离线存储的网站。我使用Web Worker在后台运行一些数据库查询。
在最新版的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);
};

但是,如果 Web Worker 是动态加载的而不是从文件中加载,它就能正常工作:

http://jsbin.com/warokilodi/12/edit?html,js,console,output

除了动态加载 worker 之外,是否有其他解决方法/修复方法?

1个回答

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接