3

I need to launch to launch an external url / website in Onsen Ui without leaving the app. I can use an iframe I guess between the ons-page tags where I need it but not very reliable perhaps.

Its my first Onsen Ui project.

Jimmy

Michele Giuseppe Fadda
  • 1,302
  • 1
  • 17
  • 26
Jimmy G
  • 303
  • 1
  • 2
  • 11

2 Answers2

3

Simply using the method below on OnsenUI

<a href="www.example.com">Link</a>

will destroy and replace the whole app (web view) with external HTML resources.


Solution: so you may need the helps of cordova-plugin-inappbrowser plugin.

In your case, launch an external url / website in Onsen Ui without leaving the app, you need "_self" or "_blank" ("_blank" is used for example codes below)

// opts is optional depend on your requirements
var opts = 'location=yes';
var ref = cordova.InAppBrowser.open('http://www.example.com', '_blank', opts);

or you can use ngCordova's $cordovaInAppBrowser

angular.module('app')
    .controller('ctrl', ['$cordovaInAppBrowser', function($cordovaInAppBrowser) {
         var opts = {location: 'yes'};
         $cordovaInAppBrowser.open('http://www.example.com', '_blank', opts);
     }]);
Trtshen Chaw
  • 353
  • 2
  • 10
0

i faced the same problem and i use this method its not fancy but it workes for me

<a class="name" href="#" onclick="window.open('https://www.youtube.com/watch?v=_OOWhuC_9Lw', '_system', 'location=yes'); return false;">
      Watch
</a>