views:

131

answers:

1

I was playing around trying to create a small safari extension, most for the fun of it and to see what you could do etc.

Anyways I was thinking about storing some data for my extension in a local database, so I always would have it where I needed it, across page loads.

I searched a bit on google and found this snippet from the Safari Reference Library, that will create a JavaScript database:

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

This works pretty well and creates the database like I wanted. The only thing is, that this database is domain specific, so my script creating the database will create a database for each domain visited, which wasn't exactly what I wanted.

So how can you, if possible, create a local storage database, that can be assigned to an safari extension, so it will be available on all domains?

+2  A: 

The correct way would be to do it from the global page instead of from an injected script. Problem is, it won't work.

Creating an offline database from a global page triggers a SECURITY_ERR. It is a known bug, and it should be fixed in the next release.

So, right now, there's no way to do it.

zneak
That's too bad, I guess I'll have to brace myself.
googletorp
@googletorp: Yeah, it's really a shame. :/
zneak