Opening links with Inappbrowser plugin

I used curl to get my content and within the content it contain links that I need them to open in system browser. I came across this plugin : http://plugins.cordova.io/#/package/org.apache.cordova.inappbrowser

But how should I use it?

Take a look at ngcordova, the docs for the inappbrowser can be found here: http://ngcordova.com/docs/#InAppBrowser

ngcordova is basically an angularjs wrapper for cordova plugins, making it much easier to use. Code for the inappbrowser specifically can be found here:

Add the factory to your app or controller. Afterwards you can inject $cordovaInAppBrowser to your controller and use it as described in the docs.

1 Like

I found a simple solution

	getTopicContent.request($stateParams.topicId).success(function(data){
    	$scope.threadContent = data;

    	//open in external browser
          $timeout(function () {
		   $('.mylink').click(function () {
		     var url = $(this).attr('href');
		     window.open(encodeURI(url), '_system', 'location=yes');
		     return false;
		   })
		})
    });

Hi @eldy,

If you ever want to ditch jQuery, here is another solution for opening all links in the InAppBrowser:

Just change the “_blank” to “_system” when following the tutorial. You may experience better performance without jQuery.

Regards,

1 Like

Hi nicraboy,
Thanx for the tip on dynamic links. You saved my day.
Cheers

No problem buddy :smile: