External links or url doesn't work on phonegap

心已入冬 提交于 2019-12-23 09:38:38

问题


I'm trying to develop an application using phonegap (1.1.0), xcode4 and jqtouch. The problem is that I can't open any external link. For example if I write an anchor tag with this href attribute:

href="http://www.google.com"

when running the app and clicking on the link i get this error:

ERROR whitelist rejection: url='http://www.google.com/'

As reading into different forum the application should at least open the link into safari but it doesn't happen.

Another example. If I insert an image tag that refers to an online source like this (in this I use tomcat to upload the data)

src="localhost:8080/myimage.jpeg"

it doesn't work too.

Is there any setting that I have to manage into xcode?

Any idea or advice would be very appreciate. Thanks.


回答1:


I had this issue yesterday as well. The newer version of PhoneGap requires you to add external urls to the whitelist.

I found the solution here: Link




回答2:


You have to add allowed URLs into PhoneGap.plist's (or Cordova.plist) ExternalHosts array.

For example, if you want to allow access to this URL http://www.myhost.com/path/file, then add www.myhost.com as a new entry to ExternalHosts array.

If you want to allow access to content on all the subdomain of Google (e.g. maps.google.com, mails.google.com), you can add *.google.com as a new entry to ExternalHosts array.

Attention when adding a host to the list! The small arrow needs to be pointing down BEFORE you click in the + signal




回答3:


Just write the link like this for phonegap 2.4.X

<a onClick='window.open("http://www.google.com/", "_system");' href='http://www.google.com' />


来源:https://stackoverflow.com/questions/7752732/external-links-or-url-doesnt-work-on-phonegap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!