Handling iframes in Android WebView

I have an iframe embedded in html that loads a google ad. The problem is when the ad is clicked, the website that it associates with the downloads in the tiny iframe, instead of opening a new WebView to display it correctly. I searched quite a bit on StackExchange and found several similar problems, but none of the solutions worked for me. I tried to use the return value false from mustInterceptUrlLoading (never even called), shouldInterceptRequest (never called), onPageFinished (called when loading the original page, nothing when clicking on iframe) and onLoadResource. This last method got me the closest, but when I try to load the URL data, it infinitely stacks new, empty WebView snippets, rather than loading the page as I expected. Can someone explain to me the correct way, from within the WebView, to detect the click of an iframe, to capture the webpage that the ad is trying to load, and manually open it in a new WebView?

+5
source share

Source: https://habr.com/ru/post/1201091/


All Articles