Open links from server generated html in inAppBrowser

Hi guys,
I have very specific probleme on which I need help.

So I have to display server side generated html on which i have no power.

This html sometimes contains <a tags with hrefs.

I’m using a trick i’ve seen around here where I capture the click event on the text and check if the element is a

tapOnText(e) {
if ( {
let element = || e.srcElement;
if (element.tagName == ‘A’ ) {
return false;

and then i follow the normal process of opening something with inAppBrowser.

But here is the twist. For some reasons my links sometimes are part of text blocks that are contained within tags.
In such occasion, the span fire the event that get my tapOnText function, is not recognized as an <a and my link won’t open.

Any idea how i could fix that?

Hi, maybe you could try to find the <a inside the tapped element when ‘e’ doesn’t have a target?

if ( {
} else {
let linksInsideSpan = e.querySelectorAll('A');
return false;

Good Luck!

Hi thanks for your answer.
It took me some time to come back to and try this out.

It doesn’t fix my issue since the span is recognized as a target. Also the span may contain multiple links and i need to know which one is supposed to open.

Another weird thing is that if i tap a lot on the link at some point it will open.

If that may ring a bell to anyone, the only difference I found in the faulty spans is that they contain &nbsp.