2013-07-16 125 views
0

我測試的應用程序,我用Dreamweaver jQuery Mobile的本地製造能夠從server.after編譯我用Dreamweaver PhoneGap的應用程序訪問外部資源,我發現我的應用程序無法遠程連接來訪問外部資源。我使用了日食,我能夠使用super.loadUrl("http://webaddress/folder/index.html");指出我的應用程序的起點。有什麼方法可以指出我的應用程序的起點,使用我的config.xml作爲dreamweaver phonegap。訪問外部資源與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="[email protected]"> 
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> 

回答

0

添加<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=".*"/> 
+0

請我應該用我的服務器地址替換IP地址?例如<訪問起源=「http://myaddress.com*」/> – user2522201

+0

@Arjun它可以使用兩個? –

2

爲了訪問外部資源PhoneGap的V3.1:
打開config.xml文件,更改:

<access origin="http://127.0.0.1*"/> 

<access origin="*" /> 

的*作爲通配符來表示任何值可以去那裏,所以<access origin="*"/>表示該應用被允許訪問Internet上的任何種源。