Android ICS上的WebView,android_assets的iframe问题

rup*_*pps 37 iframe android webview android-assets android-4.0-ice-cream-sandwich

我的应用程序引擎在WebView中运行.它跨越不同的IFRAMES.主要应用程序html和iframes html都在android_assets上.在Android 3.x上没有任何问题.在Chrome浏览器等上也是如此

如果我创建了一个IFRAME(createElement - > appendChild),则会创建iframe.

当我在其中加载内容时(iframe.src ="url"<> iframe.contentWindow.location.href ="url")...它取代了主要应用程序!! (而不是加载到iframe)

已经尝试过:

  • window.setTimeout延迟加载......失败.
  • 在webview中,将X-Frame-Options = SAME_ORIGIN作为标题注入任何加载的页面 - >失败
  • 创建iframe,设置sandbox = same_origin,allow_scripts - >失败

有类似问题的人吗?或者有人可以帮助我找到有关WebView ICS错误和Honeycomb的文档吗?

还发现了许多其他奇怪的问题...... ICS真的是这个车吗?:S:S

小智 2

先生们,我在 Android Ice Cream Sandwich (4.0.3) 中使用 Phonegap (Apache Cordova) 和 IFrames 时遇到了同样的问题。

为了解决这个问题,我不得不编辑 Apache Cordova 源代码。我更改了 org.apache.cordova。CordovaWebViewClient.java文件,并注释了这部分代码,并包含最后一行(return false;)。

所以现在看起来像这样:

    // All else
    //        else {
    //
    //            // If our app or file:, then load into a new Cordova webview container by starting a new instance of our activity.
    //            // Our app continues to run.  When BACK is pressed, our app is redisplayed.
    //            if (url.startsWith("file://") || url.indexOf(this.ctx.baseUrl) == 0 || ctx.isUrlWhiteListed(url)) {
    //                this.ctx.loadUrl(url);
    //            }
    //
    //            // If not our application, let default viewer handle
    //            else {
    //                try {
    //                    Intent intent = new Intent(Intent.ACTION_VIEW);
    //                    intent.setData(Uri.parse(url));
    //                    ctx.startActivity(intent);
    //                } catch (android.content.ActivityNotFoundException e) {
    //                    LOG.e(TAG, "Error loading url "+url, e);
    //                }
    //            }
    //        }
    //        return true;
    return false;
Run Code Online (Sandbox Code Playgroud)

这个问题仅发生在 Android ICS 上,但我更改了所有应用程序的代码。我还在做测试。

在我的分析中,似乎当您尝试在 iFrame 内加载页面时,ICS 上的 Android WebView 将其解释为新页面请求,并且它取代了主应用程序!,或者换句话说,它在洞父窗口中打开请求的页面。

我保留了其余代码不变。

我希望它能有所帮助,就像它对我一样。

此致。

亚历山大·阿尔梅达