how to work with pop ups window in android webview

半城伤御伤魂 提交于 2019-12-01 21:24:41

问题


I am developing browser like application using a Webview for my own understanding.

I am not yet clear how to work with pop-ups in android Webview.

I came across these methods onJsAlert(), onJsBeforeUnload(), onJsConfirm() etc to handle java script pop ups. from this link and also developer link

these work when there is a jsAlert but how do i handle pop-up which opens in new window ?

I just want to know is there is any other way to handle pop up for websites in android webview like opening in new tab or open in new window using webview.

I am also having trouble to open urls which are opened in new window in normal browser.e.h If I open some link from twitter then this url is not loaded but twitter logo is seen similar to one of the questions here

here is the snap shot from normal android browser but this is loaded in my webview as a normal page not as pop-up


回答1:


Try

 webViewObject.getSettings().setJavaScriptCanOpenWindowsAutomatically(true)

if you want to open window...like window.open thn its required. for the javascriptenable should be set to true.. hope i understand ur quest correct.



来源:https://stackoverflow.com/questions/10169821/how-to-work-with-pop-ups-window-in-android-webview

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