2012-01-17 45 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。