How can i detect when Webview goes out of index.html?


#1

Hi, I have some iframe elements inside my page, and the user clicks the elements (mostly a elements) inside these frames, it navigates to the target web page but stays inside the app. Ionic App (Webview that contains my app) changes its content html to the new page, but I want to open this new page with system browser. How can i detect this navigation and force it to open in system browser? Btw, I use Ionic 2.


#2

For all I know you can’t. Since these events occur inside your iFrame and not inside your Ionic app. I tend to avoid Iframes, because they come with all sort of problems. The only thing I can think off is that if you control the origin of the iFrame that you somehow find a way to send a message from the iFrame up to your Ionic app. I’m thinking of something like this, but I don’t have any clue how this will behave in a Cordova app.

Some stuff about window.postmessage here:


#3

Unfortunately i can’t control iframe origin.


#4

Then I would suggest not using iFrames. Maybe you can live with an iFrame to display some content only (but I wouldn’t salute it in an Ionic app anyway), but if you need to interact with it and you don’t control the origin I don’t see any chance of getting this to work.