External links can't go back

Hi. I’ve got external links in my app. My problem is: When a user clicks a link on iPhone you can’t go back. You then need to restart the app to be able to get back to the actual app. Ideal would be if you could add a “Back” button when you’ve clicked an external link. Opening the link in your browser instead would also be good.

Is there a way to fix this?

Thanks in advance.

Hi @mtnptrsn,

This may be useful for you.

Hmm… Don’t you need to programmatically open links with that? I mean you need to do this.iab.create('https://ionicframework.com/'). On my app there are links (anchor tags) Is it possible to replace the original behaviour and open it via inAppBrowser?

You can replace the href link on your anchor tag and call the function on click on it and then in that function you can call the this.iab.create('https://ionicframework.com/') this.

I wish it was that easy :confused: The problem here is: My anchor tags are being generated by script-tag. (Nothing I can do about that) So there is no way for me to change how the anchor tag looks like.

<script>
    document.onclick = function (e) {
        e = e ||  window.event;
        var element = e.target || e.srcElement;

        if (element.tagName == 'A') {
            window.open(element.href, "_blank", "location=yes");
            return false;
        }
    };
</script>

May be this can help you.

That’s a good idea. It didn’t work though. Since it didnt work I had to inspect the ads and it seems like its not even a-tags. (It is ads from adform)

The way they redirect you to the website is this:

document.getElementById("image").addEventListener("click",function(){var e=Adform.getClickURL();window.mraid&&mraid.open?mraid.open(e):window.open(e,"_blank")},!1)

Isn’t that weird, tho? It says '_blank' but it still doesnt open in a new window.

Do you have any idea how I could solve this?

Is it possible to change the default behaviour of window.open? That could actually be the sulotion.