Max Power
Max Power

Reputation: 75

ios cordova app redirect and opens in browser

I have a cordova app. Its pointed to a web page. But the web page goes out and pulls a value, actually depending on a value which page to redirect to. Either A.html or B.html depending on the value.

The problem I'm having is in the cordova index.html page I have javascript trying to redirect to the new page. After I have pulled the value, redirect to the page string that came in.

window.location.replace("/site/" + this.responseText);

The problem I having is in ios, the splash screen comes up, the app shows for a second then it opens up a browser to the new page. I want the page to say inside the app?

The solutions on stackoverflow give some ideas to handle the click event and catch it. There is no real click event. I also would like to do it just in JavaScript.

Any idea?

Upvotes: 0

Views: 1582

Answers (1)

Max Power
Max Power

Reputation: 75

The way to do this in cordova is through config.xml You have to have

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

This will allow those external sites to still show up in the app WebView.

I also had to change the intent.

<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />

Cordova sets these up to default any link to open outside. Changing to only the URLs that need to go outside the app.

<allow-intent href="https://www.yahoo.com/*" />

Upvotes: 2

Related Questions