2

I am wrapping a responsive website into a Cordova app for Android and iOS. In my DeviceReady I just open window.location="http://website" and all internal links work fine and stay in app view.

Now I would need some links to open into system browser. Biggest reason for this is iPhone's / iPad's missing the back button and it is hard to navigate back to the website.

All my "code" is in website and Cordova just wraps the website into a "mobile app".

What can I say in website code to make Cordova to open system browser. I have tried window.open(..., "_system"), "_blank" etc. and with normal link as target="_blank" but still all these are opened in my app view, that is, not in system browser.

How can I force a link to be opened in the System Browser?

All help appreciated! Cheers :)

h7r
  • 4,944
  • 2
  • 28
  • 31
Kimmo
  • 21
  • 3

2 Answers2

4

You need to install this plugin first

inAppBrowser

then try opening with

window.open(..., "_system")
AtanuCSE
  • 8,832
  • 14
  • 74
  • 112
  • 1
    Hi, I have installed inAppBrowser and added it also into config.xml file Then had also used window.open(..., "_system") in website code but either iOS nor Android open that with "browser" but keeps the view in application. – Kimmo Feb 08 '15 at 19:20
  • The above solution works only when called from the parent Cordova webview, where `cordova.js` is available and `window.open` = `cordova.inAppBrowser.open`. Trying to call `window.open('https://external-link.com', '_system')` from the `inAppBrowser` will keep the navigation in-app. – Franz Apr 03 '18 at 16:39
1

The problem is you are doing things wrong, you can't use cordova to just redirect to a website, that's not how cordova works, with cordova you create apps with html, css and javascript, that isn't the same than redirecting to websites.

When you redirect to a website you lose all the cordova capabilities, because you don't have the cordova.js there, so you can't use any plugin and inAppBrowser doesn't work.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Thank you for the info. That explains :) I have created also in the past also mobile apps with all the code in cordova as you mentioned. But as I create quite complex responsive websites with wordpress / PHP I would not want to create the code "again" inside cordova. In windows phone world the webapps are perfect to wrap responsive website to mobile app and there these links opens in browser (not in app). Cordova wrapper solution (just render website into cordova view) works perfectly with apps where you do not have links outside your own domain. Cheers – Kimmo Feb 09 '15 at 12:44