Take the 2-minute tour ×


I work with RapidWeaver — Mac OS X CMS application — and it uses no server environment. It has an editor and a preview mode. The preview mode is a Webkit based renderer, and I can use 'Inspect Element', like you normally could do in Safari.

I want to store some settings for a toolbar, either using localStorage or SQLite. I have read some information about indexedDB, though I have found no concrete implementations on how to use it.

Problems with localStorage

localStorage works fine when I stay in the preview mode, when I switch between editor and preview mode the url — location.href — is slightly altered:



document-143873968-28 changes into document-143873968-29

What I have read about localStorage, that it's basically globalStorage[location.hostname] for FireFox. As far as I know globalStorage is not supported in Safari, so I can't try that.

Problems with SQLite

When I try to open a 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);

I get this in my console:


That basically wraps up my question, I will appreciate any answers or comments sincerely.

share|improve this question
add comment

2 Answers

localStorage is a html5 mechanism to give scripts a bit more space than cookies. Safari supports it: http://developer.apple.com/library/safari/ipad/#documentation/iPhone/Conceptual/SafariJSDatabaseGuide/Name-ValueStorage/Name-ValueStorage.html

I don't know offhand what, if any, path restrictions it should have for file:/// based apps.

Edit: looking into the path restrictions further, I see that what you got should work with Safari, FF recently fixed a bug that would keep it from working there: https://bugzilla.mozilla.org/show%5Fbug.cgi?id=507361

share|improve this answer
It's not working for me, also I tested localStorage on localhost using MAMP with no luck. –  jeroen Sep 24 '11 at 19:30
add comment

Using the following solution: Implementing a WebView database quota delegate with a few modifications I was able to get it to work.

The following delegate method worked for me (place in your webViewDelegate):

- (void)webView:(WebView *)sender frame:(WebFrame *)frame exceededDatabaseQuotaForSecurityOrigin:(id) origin database:(NSString *)databaseIdentifier
  static const unsigned long long defaultQuota = 5 * 1024 * 1024;
  if ([origin respondsToSelector: @selector(setQuota:)]) {
    [origin performSelector:@selector(setQuota:) withObject:[NSNumber numberWithLongLong: defaultQuota]];
  } else { 
    NSLog(@"could not increase quota for %@", defaultQuota); 

By default the database is given 0 bytes, which results in the vague error message you get above. The above method is called after an attempt is made to create a database when there is not enough space. Note that this method is defined in WebUIDelegatePrivate.h ( http://opensource.apple.com/source/WebKit/WebKit-7533.16/mac/WebView/WebUIDelegatePrivate.h ) and using may preclude you from submitting your app to the mac app store.

share|improve this answer
add comment

Your Answer


