12

I'm stuck. I'm working on a iOS phonegap app. On my homepage I have a link

<a href="http://www.mysite.com/file/news.html" rel="external" target="_system"><IMAGE></a>

And I have also added *mysite.com into the Cordova.plist (ExternalHosts).

But when I click on the link it will open up a browser and link me to that page. I have tried target="_self", but it doesn't work. How to make it open the page within the app itself?

NOOPA
  • 135
  • 1
  • 2
  • 7
  • See the following [answer](https://stackoverflow.com/questions/47547852/phonegap-inappbrowser-not-working-need-to-open-the-url-inside-the-app?noredirect=1&lq=1#): it at least worked on Android for me. – Fritz Dodoo Jun 25 '18 at 21:14

2 Answers2

3

You can push it to browser using this javascript snip,

window.open("http://yourexternallink.com","_system");

Even if you have inAppBrowser installed, this will take you to browser..

If you wish to open the link inside your app, you need below snippet,

var onInApp = window.open('http://paymentpage.com', '_blank', 'location=no,hidden=yes,closebuttoncaption=Done,toolbar=no');

make sure that you added cordova plugin add cordova-plugin-inappbrowser plugin..

Vinith
  • 1,264
  • 14
  • 25
  • i'm using cordova, and i don't thing the plugin run differently through these two engine, but it doesn't worked for me – Hassan Faghihi Jan 13 '16 at 06:31
  • setting hidden to no made it work, and it work better than the other answer, i edit it for you, you can accept or reject once you check – Hassan Faghihi Jan 13 '16 at 06:44
  • If you are sure about the answer please edit... This was posted months ago and number of versions released after that.. thanks – Vinith Jan 13 '16 at 12:00
  • i'm sure, also another way is to say the browser to become visible later, but normally you wont see a thing by using above code. you need to edit, or approve my edit as i already done that – Hassan Faghihi Jan 13 '16 at 12:05
  • Please refer this link, you'll get more idea, https://cordova.apache.org/docs/en/3.0.0/cordova/inappbrowser/inappbrowser.html – Vinith Feb 24 '16 at 07:11
  • I try all thinks but link is stillopening in browser, I just want to open with in app – Amarjit Feb 24 '16 at 18:44
0

Use inApp Browser link

The InAppBrowser is a web-browser that is shown in your app when you use the window.open call.

in ios add

<plugin name="InAppBrowser" value="CDVInAppBrowser" /> to config.xml and just call window.open('http://apache.org', '_blank', 'location=yes'); etc.. more info link

Arjun T Raj
  • 3,187
  • 1
  • 21
  • 44