[英]Accessing external resources with phonegap
我測試了一個我用Dreamweaver本地構建的應用程序jQuery mobile能夠從服務器訪問外部資源。在使用dreamweaver phonegap編譯我的應用程序后,我發現我的應用程序無法遠程連接以訪問外部資源。 我使用了eclipse,我能夠使用super.loadUrl("http://webaddress/folder/index.html");
指出我的應用程序的super.loadUrl("http://webaddress/folder/index.html");
。 有什么方法我可以使用我的config.xml為Dreamweaver phonegap指出我的應用程序的起點。
<?xml version="1.3.1" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.3.1"
id = "com.phonegap.example"
version = "1.3.1.0">
<name>Go tv app</name>
<description>
A simple PhoneGap Build application.
</description>
<author href="https://example.com" email="you@example.com">
Benjamin Blay
</author>
<feature name="http://api.phonegap.com/1.3.1/device" />
<preference name="phonegap-version" value="2.0.0" />
<preference name="orientation" value="default" />
<preference name="target-device" value="universal" />
<preference name="fullscreen" value="false" />
<preference name="stay-in-webview" value="true" />
<!-- Icons -->
<icon src="icon.png" />
<icon src="images/icon-72x72.png" width="72" height="72" gap:platform="android" gap:density="hdpi" />
<icon src="images/icon-96x96.png" width="96" height="96" gap:platform="android" gap:density="xhdpi" />
<icon src="images/icon-72x72.png" width="72" height="72" gap:platform="ios" />
<!-- Splash Screens -->
<gap:splash src="splash_screen.jpg" />
<gap:splash src="images/splash_screen-160x220.jpg" gap:platform="android" gap:density="ldpi" />
<gap:splash src="splash_screen.jpg" gap:platform="android" gap:density="mdpi" />
<gap:splash src="images/splash_screen-450x650.jpg" gap:platform="android" gap:density="hdpi" />
</widget>
要在Phonegap v3.1中訪問外部資源:
打開config.xml文件,更改:
<access origin="http://127.0.0.1*"/>
至
<access origin="*" />
*用作通配符,表示任何值都可以去那里,因此<access origin="*"/>
表示允許應用訪問Internet上的任何資源。
將<access origin=".*"/>
到您的confog.xml,請使用最新的phonegap版本
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
<access origin=".*"/>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.