1

I have a problem. I need to return to parent Url from Frame opened in a Android Webview.

The sequence is: Open inside Webview new frame. Select in frame options and paramters. Call in frame javascript function like _"javascript:parent.opener.jsfunction"_. Parent Web doesn't open... I don't have access to Web. I work only in Android side.

I test Web in a firefox for Android and it works.

Need help.

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96
Nacho
  • 13
  • 1
  • 4

1 Answers1

1

By default, WebView doesn't support multiple windows. If you check, I believe the parent field actually isn't set and doesn't point to the parent window (or anything at all). The same applies to other similar fields like opener and top.

You might be able to work through this by enabling support for multiple windows and then implementing onCreateWindow in your WebChromeClient. I think there's some more you have to do, but it's been a while and I don't recall the details.

One way I've hacked around this in the past is to use setJavascriptInterface and just set the name to parent or whichever field you want. Implement the appropriate methods as necessary on your Java object. This can get a bit messy, but it works.

kabuko
  • 36,028
  • 10
  • 80
  • 93
  • Thanks, Finally I found the solution enabling support for multiple windows and then implementing onCreateWindow in your WebChromeClient. Aftre a lot of test work it! – Nacho Mar 01 '13 at 12:48
  • Would you please share what you did in the onCreateWindow(), I have a problem uploading an image via webView and I got this error, "Uncaught TypeError: Cannot set property 'value' of null", source: " – A. Albrg May 27 '20 at 16:06