Web workers and JS database

Hi there,

I'm trying to create a JS database from within a web worker, in order to maximise UI when undertaking expensive DB queries. I have the web worker and main JS thread successfully communicating back and forth. However, I can't create a JS database and get the error:

"Can't find variable: openDatabase".

Is creating a JS database from within a web worker supported in Safari? Does this mean that Safari only supports JS database from a normal thread (not a worker)? Or is my syntax wrong? Or does interaction with the database not impact UI/DOM resposiveness? (There aren't many examples to go from.)

If anyone could point me in the right direction, that'd be grand.

Kind regards,

Mark
The web worker JS (just the highlights) is:

if (addEventListener) {
addEventListener("message", _onMessage, false);

} else if (attachEvent) {
attachEvent("onmessage", _onMessage);

} else {
return;

}

function _onMessage(e) {

var message = JSON.parse(e.data);

switch (message.command) {

case (DB_INIT):

try {

if (!window.openDatabase) {

postMessage("some reply");

} else {

var shortName = 'mydatabase';
var version = '1.0';
var displayName = 'My Important Database';
var maxSize = 65536; // in bytes
var db = openDatabase(shortName, version, displayName, maxSize);

postMessage("some reply");

}

} catch (e) {

// Error handling code goes here
return;
}
break;

};
};

Macbook Pro, Mac OS X (10.6.2)

Posted on Dec 16, 2009 9:39 PM

Reply

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Web workers and JS database

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.