Prevent open external browser. Force to open all a-href with InAppBrowser


#1

Is it possible to open all a-tag href links with the in-app-browser plugin?

Use case:
The google map terms-link opens the external browser (a-href).
This invokes the OnBeforeUnload which contains the BLE.disconnect() function. Necessary for ionic livereload. This is weird, usually only the pause-event is called. Also on switching apps. But only if I clicked a-href the OnBeforeUnload-Event is also invoked. Whatever … I want to force to open ALL links with the in-app-browser. I can’t modify the google maps links. (it’s not allowed at all)

Overwrite window.open does not work. Because it’s a a-tag href-link.


#2

One (ugly) solution:

document.onclick = function (e: any) {
  if (e.target.tagName == 'A') {
    window.open(e.target.href, "_blank", "location=yes");
    return false;
  }
}

Any (better / other) alternatives?

Update: Btw. the Google Logo opens the Map App installed on the device. It is also a A-Tag (AnchorElement) with href. But this does not matter. The system switches to the Map App. So my problem is not completly solved. -.- Where is the half-solved button here? :smiley:

Update: It seems to be a javascript execution of google.maps listen to a click event of the google logo on the map and opens the map app. This has nothing to do with the href-link.

Issue: google maps logo opens the external map app.
Workaround: Overlay a transparent div to block the click event.