【问题标题】:SECURITY_ERR: DOM Exception 18 on iOS 5.1 when upgrading app with WebView that opens local databaseSECURITY_ERR:使用打开本地数据库的 WebView 升级应用程序时,iOS 5.1 上的 DOM 异常 18
【发布时间】:2013-01-21 19:37:00
【问题描述】:

如果您构建一个简单的 Titanium 移动应用程序,其中包含一个 WebView,其中包含打开本地数据库的 javascript,第一次将其安装到 iOS 5.1 设备时,它将正确打开数据库。但是,如果您随后在设备上升级应用程序(它仍然可以是完全相同的版本/构建),则在打开本地数据库时会出错:

SECURITY_ERR:DOM 异常 18

重现步骤:

  1. 将下面的 app.js 和 database.html 文件添加到 Resources 的根目录中。
  2. 将应用安装到 iOS 5.1 设备(在 Ti Studio 中运行 > iOS 设备)。
  3. 打开应用,它会说“db opens”。
  4. 在 iOS 5.1 设备上升级应用(在 Ti Studio 中运行 > iOS 设备)。
  5. 打开应用,会提示“db opening failed: Error: SECURITY_ERR: DOM Exception 18”。

这里是重现的代码:

app.js:

var win = Ti.UI.createWindow({});
var webView = Ti.UI.createWebView({
    top : 0, right : 0, bottom : 0, left : 0, url: 'database.html'
});
win.add(webView);
win.open();

数据库.html:

<!DOCTYPE HTML>
<html>
    <head>
        <title>db test</title>
        <script>
            window.onload = function () {
                var dbConn;
                try {
                    dbConn = openDatabase('test', '0.1', 'test database', 5 * 1024 * 1024);
                    alert('db opened');
                } catch (e) {
                    alert('db opening failed: ' + e.toString());
                }
            };
        </script> 
    </head>
    <body>
        db test
    </body>
</html>

这个问题似乎与 Apache Cordova 已经解决的问题相同。

https://issues.apache.org/jira/browse/CB-347

还有其他人遇到过这个问题吗?有什么解决方法的想法吗?

【问题讨论】:

    标签: ios ios5 webview titanium titanium-mobile


    【解决方案1】:

    我们最终为 iOS 创建了一个自定义 webview 模块来自己解决这个问题,谁知道 Titanium 需要多长时间才能做到这一点:

    Webview Module Source

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-04-08
      • 2011-07-27
      • 2019-11-11
      • 1970-01-01
      • 2015-10-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多