Not able to navigate to certain URL in cordova

2.8k views Asked by At

I'm not able to navigate to a certain URL when I'm using the following command:

window.location.href = "http://google.com";

In my cordova config.xml file I already specified to access to all sources using the default cordova setting with the wildcard:

<access origin="*" subdomains="true" />

Here is what location prints to the console:

Location {replace: function, assign: function, ancestorOrigins: DOMStringList, origin: "file://", hash: ""…}
ancestorOrigins: DOMStringList
assign: function () { [native code] }
hash: ""
host: ""
hostname: ""
href: "file:///android_asset/www/index.html"
origin: "file://"
pathname: "/android_asset/www/index.html"
port: ""
protocol: "file:"
reload: function reload() { [native code] }
replace: function () { [native code] }
search: ""
toString: function toString() { [native code] }
valueOf: function valueOf() { [native code] }
__proto__: Location

I'm running my application in Android with the cordova 5.1.1 version.

1

There are 1 answers

3
Guillaume Munsch On BEST ANSWER

Sometimes, the default access settings aren't enough, i don't really know why, but i think i know how to patch this.

Try to install this plugin :

cordova plugin add https://github.com/apache/cordova-plugin-whitelist

And then, in your config.xml, add this line

<allow-navigation href="http://google.com/*" />

Compile again and tell me how it's going on ! :)