Search code examples
cordovaphonegap-pluginscordova-plugins

Cordova 6 : how to stay in app when opening an external url?


I tried ALL solutions

 navigator.app.loadUrl('http://www.google.fr', {openExternal:false});

function onDeviceReady(){
   window.location.href = 'http://www.google.fr';
 }

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

All open a NEW browser and leaves the cordova application !

I even tried some iframe solution but I got errors as well.

I succeed with inAppBrowser BUT, this solution is not good since it goes ON top of the application and hides admob ads displayed on application.

My goal is SIMPLY to display my website AS application: so cordova just naviagtes to external url on deviceReady !


Solution

  • Using the InAppBrowser Plugin you should be able to do:

    cordova.InAppBrowser.open('http://apache.org', '_self', 'location=yes');
    

    Notice the _self target in the second parameter. This will open the site in the app's WebView.