javascript iPhone 上的 PhoneGap 不会加载外部脚本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8035701/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PhoneGap on iPhone wont load external scripts
提问by James Hughes
I am currently writing a simple application using PhoneGap (iOS) and running it in the simulator. The problem is that external URLs seem to refuse to load. For example using a CDN for jQuery
我目前正在使用 PhoneGap (iOS) 编写一个简单的应用程序并在模拟器中运行它。问题是外部 URL 似乎拒绝加载。例如使用 jQuery 的 CDN
<script type="text/javascript" charset="utf-8" src="http://code.jquery.com/jquery-1.7.min.js"></script>
Will not make $
/jQuery
available. The same problem is happening for weinre when trying to use it. Is there something I need to change to enable this to work?
不会使$
/jQuery
可用。在尝试使用 weinre 时,也发生了同样的问题。是否需要更改某些内容才能使其正常工作?
回答by Devgeeks
Have you added the domains of the external links to the ExternalHosts entry in PhoneGap.plist ?
您是否将外部链接的域添加到 PhoneGap.plist 中的 ExternalHosts 条目?
There is a fairly new whitelisting system in PhoneGap that is causing a bit of confusion with external links
PhoneGap 中有一个相当新的白名单系统,这导致了与外部链接的一些混淆
From - http://wiki.phonegap.com/:
来自 - http://wiki.phonegap.com/:
"Also, 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)."
“此外,最新代码具有新的白名单功能。如果您要引用外部主机,则必须在“ExternalHosts”键下的 PhoneGap.plist 中添加主机。通配符可以。因此,如果您要连接到“ http://phonegap.com”,您必须将“phonegap.com”添加到列表中(或使用通配符“*.phonegap.com”,它也将匹配子域)。”