2016-01-23 78 views
3

我使用phonegap创建了一个构建。在index.html文件中,我编写了一个用于加载网站的简单iframe。它的工作时,我从手机本地URL。但它不工作,如果我上传整个构建作为电话中的zip,然后从它下载apk文件。然后尝试在手机中安装该apk,显示应用程序错误。Phonegap(应用程序错误...发生网络错误)

我已经检查过访问起源,并试图给它里面的域名。但它根本没有工作。任何人都可以帮助我。

的config.xml和index.html给出这样下面

<access origin="*"/> 

<html> 
 
    <head> 
 
     <meta charset="utf-8" /> 
 
     <meta name="format-detection" content="telephone=no" /> 
 
     <meta name="msapplication-tap-highlight" content="no" /> 
 
     <!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 --> 
 
     <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" /> 
 
     <title>Testing</title> 
 
    </head> 
 
    <body> 
 

 
<iframe src="http://www.w3schools.com" height="640px" width="100%" frameborder="0" scrolling="yes"> 
 
</iframe> 
 

 
    </body> 
 
</html>

+0

检查这个页面 - https://github.com/apache/cordova-plugin-whitelist/blob/master/README.md#content-security-policy - (<! - 允许iframe到https://cordova.apache.org/ - >) - 应该这样做。让我知道她生病后作为回答 – Tasos

+0

看来,由于相同的原产地政策,不可能以这种方式从不同的域加载到您的应用程序,你给[cordova-plugin-inappbrowser](https: //github.com/apache/cordova-plugin-inappbrowser)试试吗? – Blauharley

+0

@Tasos它不工作:(。仍然显示一个空白的白色屏幕:( –

回答

1

你犯了一个常识性错误。您需要应用whitelist系统。需要截至Cordova Tools 5.0.0(2015年4月21日)。对于的PhoneGap构建,这意味着自cli-5.1.1(2015年6月16日)

白名单工作应该有所帮助。
HOW TO apply the Cordova/Phonegap the whitelist system

添加到您的​​3210

<plugin name="cordova-plugin-whitelist"  source="npm" spec="1.1.0" /> 
<allow-navigation href="*" /> 
<allow-intent href="*" /> 
<access origin="*" /> <!-- Required for iOS9 --> 

注意:您的应用现已不安全。它是由你来保护你的APP。

以下添加到您的index.html

<meta http-equiv="Content-Security-Policy" 
     content="default-src *; 
        style-src * 'self' 'unsafe-inline' 'unsafe-eval'; 
        script-src * 'self' 'unsafe-inline' 'unsafe-eval';"> 

注意:您的应用现已不安全。它是由你来保护你的APP。

+0

让我检查并告诉你 –

相关问题