parent.opener doesn't work in webview Android

谁说我不能喝 提交于 2020-01-05 06:55:13

问题


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.


回答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.



来源:https://stackoverflow.com/questions/15142707/parent-opener-doesnt-work-in-webview-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!