5

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.

0

2 Answers 2

3

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

example: iFrame src change event detection?

3
  • 1
    You'd have the javascript call something you added with addJavascriptInterface
    – JeffS
    Commented Feb 20, 2013 at 22:22
  • Sorry if I wasn't clear enough but mentioning shouldOverrideUrlLoading() and its siblings should have indicated that I'd need this functionality in Java code, not inside the browser in the iframe.
    – Gábor
    Commented Feb 22, 2013 at 21:33
  • This second comment seems interesting. Thanks, I'll report back.
    – Gábor
    Commented Feb 24, 2013 at 12:45
0

For anyone else with this problem, we found an even more simple solution to this than calling a javascript function. Simply add "target= _top" to the iframe redirect (see http://www.w3schools.com/tags/att_a_target.asp). Then shouldOverrideUrlLoading() will be called in the Android code.

1
  • 4
    What? You can't set a target on a redirect. Your link is to information on a elements, which are rather different from redirects. I'm not familiar with the tags on this question, so I'm not certain this is about HTTP at all, but I strongly suspect this is wrong.
    – Brilliand
    Commented May 14, 2014 at 17:33

Not the answer you're looking for? Browse other questions tagged or ask your own question.