Ionic 2|3 : Open all links inside inAppBrowser


Is there a way to open all links using the InAppBrowser from '@ionic-native/in-app-browser'. (

Mayby by changing the function ?

I have something like this :

<a href="">Link</a>
And i want to open the InAppBrowser when the user click on the link.

Thank you.


why would you like to use links???


That’s something i can’t change, because the template is downloaded from an external web service.


In that case you can refer to the following link:


I’ve this : = (url, target?, opts?) => {
            return null;

openLink(urlOpening: string) {
  this.browser = this.iab.create(urlOpening, '_blank', 'location=yes,clearsessioncache=yes,clearcache=yes');   

it works fine on : <p onclick="'')">link test</p>

But it doesn’t work on href .

Do you have an idea ?


try this:

 <a href="#" onclick="'', '_system', 'location=yes'); return false;">
                Open Google


Just for future reference since this forum seems to dead:

Insert this catch-all script in your app’s index.html:

    <script type="text/javascript">
        // links catch-all/handler
        document.onclick = function (e) {
            e = e ||  window.event;
            var element = || e.srcElement;
            // making sure there's an URL
            if ((element.tagName == 'A') && (element.href)) {
              // opening in a new window
      , "_blank", "location=yes");
                return false;

Then override the function. That way every links will get handled properly.