为什么Cordova 2.7.0 JS似乎不再在远程页面上工作? [英] Why does Cordova 2.7.0 JS seemingly no longer work on remote pages?

查看:220
本文介绍了为什么Cordova 2.7.0 JS似乎不再在远程页面上工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试升级基于 Cordova a> 2.0到2.7版。

I'm attempting to upgrade an iOS app built on Cordova 2.0 to version 2.7.

这是一个欢迎屏幕,指向一个远程搜索引擎(请保留关于应用程序的有效性和可能的​​批准, ),我们正在使用 ChildBrowser 插件在子浏览器中启用打开链接以便不将用户陷入Cordova网络视图。

It's basically a welcome screen that points to a remote search engine (please withhold comments about app validity and likely approval, as we're past that), and we were using the ChildBrowser plugin to enable opening links in a sub browser so as not to trap the user in the Cordova webview.

Cordova 2.7具有名为 InAppBrowser 我希望使用而不是ChildBrowser。

Cordova 2.7 has a feature called InAppBrowser I am hoping to use instead of ChildBrowser. InAppBrowser does essentially the same thing, aside from missing a button to open in Safari.

现有的InAppBrowser实际上是一样的东西,除了在Safari中缺少一个按钮才能打开。 app的远程网页包括Cordova JS(以及ChildBrowser插件),并且在子浏览器中打开链接的工作正常。

The existing app's remote webpages include the Cordova JS (as well as that for the ChildBrowser plugin) and it works fine for opening links in the sub browser.

我的测试Cordova 2.7应用程序似乎在从远程网页加载Cordova JS时正确加载它。

My test Cordova 2.7 app doesn't seem to load the Cordova JS correctly when it's being loaded from a remote web page.

我尝试在嵌入式启动页面上使用完全相同的HTML,并且远程启动page:

I tried using this exact same HTML on the embedded start page and a remote start page:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <script type="text/javascript" src="http://mydomain.com/mobile/cordova-2.7.0.js"></script>
  </head>
  <body>
    <script>
      document.addEventListener("deviceready", onDeviceReady, false);
      function onDeviceReady() {
        alert("Ready!!");
      }
    </script>
  </body>
</html>

要测试这是嵌入式起始页,我把这行放在 config .xml

To test this as the embedded start page, I put this line in config.xml:

<content src="index.html" />

当我运行应用程序时,我立即得到准备好!

When I run the app, I promptly get the "Ready!" alert.

要测试此为远程启动页面(我的目标是链接到最终应用程序中的远程页面)只要使用它作为测试的起始页,结果是相同的,如果我从嵌入的页面链接。),我把这行在 config.xml

To test this as the remote start page (I'm aiming to link to the remote page in the final app, I am just using it as the start page for testing. The result is the same if I link from the embedded page.), I put this line in config.xml:

<content src="http://mydomain.com/mobile/index.php" />

当我运行应用程序时,我只是得到空白屏幕,没有警报。

When I run the app, I just get the blank screen and no alert.

此外,在 cordova-2.7.0.js L. 6255,我更改了

Further, in cordova-2.7.0.js L. 6255, I changed

console.log('deviceready has not fired after 5 seconds.');

alert('deviceready has not fired after 5 seconds.');

在这种情况下,使用远程启动页面运行应用程序会导致空白页面,然后五秒,我得到警报deviceready没有发射后5秒。所以这告诉我Cordova JS没有正确启动。不用说,我不能让InAppBrowser在远程站点的子浏览器中启动链接,但是我可以在嵌入的开始页面上正常工作。

With that change, running the app using the remote start page causes the blank page, and then after five seconds, I get the alert "deviceready has not fired after 5 seconds.". So this tells me Cordova JS is not starting correctly. Needless to say, I can't get InAppBrowser to launch links in the sub browser on the remote site, but I can get it working just fine on the embedded start page.

任何人都有什么想法从这里去哪里?这是一个很简单的例子,所以我假设这是一个Cordova设置问题或功能的变化。

Anyone have any ideas of where to go from here? This is a pretty simplistic example, so I'm assuming this is a Cordova settings problem or a change in the functionality. I appreciate any thoughts, thanks!

推荐答案

是的,有些事情在2.7节 - 与我们的cordova-cli工作有关。请参阅: https://issues.apache.org/jira/browse/CB-3029

Yes, something broke in 2.7 - related to our cordova-cli work. See: https://issues.apache.org/jira/browse/CB-3029

修复方法是在根文件夹中添加一个名为cordova_plugins.json的空文件。

The fix is to add an empty file called "cordova_plugins.json" in your root folder.

这篇关于为什么Cordova 2.7.0 JS似乎不再在远程页面上工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆