2012-01-17 41 views

回答

16

白名單出現在iOS和Android上,但尚未在其他平臺上出現。

的iOS,它會被這裏解釋 「外部主機」 的名義下:http://wiki.phonegap.com/w/page/41631150/PhoneGap%20for%20iOS%20FAQ

Q. Links to and imported files from external hosts don't load? 
A. The latest code has the new white-list feature. If you are 
referencing external hosts, you will have to add the host in PhoneGap.plist 
under the "ExternalHosts" key. Wildcards are ok. So if you are connecting to 
"http://phonegap.com", you have to add "phonegap.com" to the list (or use the 
wildcard "*.phonegap.com" which will match subdomains as well). 

例如:

<key>ExternalHosts</key> 
<array> 
    <string>*</string> 
</array> 


對於Android,該功能目前尚未記錄雖然進行了修復,但有點bug。此線程包含一些很好的疑難解答細節:https://groups.google.com/forum/#!topic/phonegap/9NZ4J4l1I-s

簡而言之,它是xml/phonegap.xml中的'access'屬性。它使用Perl樣式的正則表達式

To allow all domains (debugging): <access origin=".*"/> 

很快,這可能是變化的語法如下:

<access origin="https://example.com" subdomains="true" /> 


白名單上黑莓被提供作爲WebWorks的框架 的一部分,並且被配置via config.xml:

https://bdsc.webapps.blackberry.com/html5/documentation/ww_developing/access_element_834677_11.html

示例項目允許通過「*」通配符訪問所有URL。