Href to an external URL displays web site but impossible to return to app

Hi,

I hve the following code on the page Info of my app (built on the tabs sample)

< ion-view title=“L’application” class=“has-header”>
< ion-content padding=“true”>
< div class=“list card”>
< div class=“item item-body item-text-wrap”>
< a href=“http://linktomysite.com”>HELP
</ div>
</ div>
</ ion-content>
</ ion-view>

The link goes to my help page, but I can’t com back to my application.
Is there a way to make it work ?

The best way is to open the site into the phone’s browser. But I don’t know how.

Thanks for your help
Adriana

Include the cordova inappbrowser plugin in your project:

https://github.com/apache/cordova-plugin-inappbrowser

…and then add target="_blank" to your <a …> tag to open it in a pop-up browser in your app. Use target="_system" to flip away from your app open it in the native browser.

1 Like

Thanks a lot ! It worked and you saved my evening :slight_smile:

1 Like

I’m having the same issue.
I’m trying not to use cordova plugins, because I basically want to also build a web app but the following code isn’t working as I expected:

HTML:

<a ng-repeat="contItems in arrayContacts" class="item item-icon-left btn" href="{{contItems.url}}" target="_blank">
        <i class="icon at-icons {{contItems.icon}}"></i>
        <h2>
            {{contItems.label}}
        </h2>
    </a>

The issue is it open inapp without any kind of back button (which ruins everything on iOS).

Is there any solution/explanation for this behaviour ?

I use this directive (with inappbrowser plugin):

angular.module(‘xxx’).directive(‘externalLink’, function(){
‘use strict’;
return {
restrict: ‘A’,
scope: {
url: ‘@href
},
link: function(scope, element, attrs){
element.bind(‘click’, function(e){
e.preventDefault();
if (typeof analytics !== ‘undefined’) {
window.analytics.trackEvent(‘event’, ‘outlink’, encodeURI(scope.url));
}
window.open(encodeURI(scope.url), ‘_system’, ‘location=yes’);
});
}
};
});

then add external-link to the that I want to open in system browser.