We have an iPhone application that is essentially a web site encapsulated in an app. This app loads the HTML and JS files from the local disk and interaction is done in JS.
However, with iOS 4.2, the JS has started receiving “SECURITY_ERR: DOM Exception 18” when opening a database, and as a result, our app doesn’t work at all. The exact same file worked fine in prior versions of iOS and works fine when loaded from a web server.
Is there a way to configure iOS to permit JS running in a local file to access a database?
Thank you!
Kevin
I guess I should answer this question since I did finally get an answer from Apple Developer Support confessing this to be a bug in iOS4.
The specific problem is when you load a webView using [webView loadData…]. When loaded this way, webKit does not allow access to databases. If the same call is changed to use [webView loadRequest…] databases are permitted.
There is sample code to demonstrate the problem here:
http://code.google.com/p/iui/source/browse/sandbox/hybrid/HybridiUI/Classes/HybridiUIAppDelegate.m
The same bug, by the way, exists in Google Chrome, which also uses webKit. When loading a web site from a local file in Chrome, databases and AJAX calls are forbidden, but when loading from a web server they are permitted.