Search code examples
javaandroidwebview

How to catch an iframe redirecting?


I have a WebView with an iframe inside. The contents of the iframe do a redirect to another URL that doesn't allow embedding in an iframe. Not a problem, actually, I just want to start the external browser activity in this case instead. The problem is that I can't find a way to intercept the redirection. None of shouldOverrideUrlLoading(), onPageStarted() or onLoadResource() get called for the redirect, hence I get no chance to start the activity.


Solution

  • In the html change the iframe tag to call some javascript function when a redirect happens

    example: iFrame src change event detection?