Cordova/Ionic app, prevent redirecting the main WebView

I have a Cordova/Ionic app that uses a 3rd party JS lib that is used for a customer feedback chat window. When the chat is opened, it redirects the whole app's webview, I want to avoid this.

The JS lib is injected into the page through a dynamic <script> tag. I can't mess with it -- or don't want to. The chat window can be opened by an API-call. There's no API function to get the URL that will be opened.

The API call redirects the whole browser app. I want to show the new page in the external browser or preferably in an <iframe>

The page works differently in Chrome dev and in mobile, e.g. Safari. This might be partially because of the lib too.

I have tried:

  • <iframe>. Not works, redirects the whole page. How can I prevent it?
  • window.onbeforeunload: Ain't fires in iOS.
  • <preference name="stay-in-webview" value="true/false" /> in config.xml

What are your suggestions? There must be something I'm missing...