如何在Android WebView中使用弹出窗口 [英] how to work with pop ups window in android webview

查看:956
本文介绍了如何在Android WebView中使用弹出窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Webview开发类似浏览器的应用程序.

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

我尚不清楚如何在android Webview中使用弹出窗口.

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

我遇到了这些方法onJsAlert()onJsBeforeUnload()onJsConfirm()等来处理Java脚本弹出窗口.从此链接以及

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

在有jsAlert时这些工作有效,但是我该如何处理在新窗口中打开的弹出窗口?

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

我只想知道是否还有其他方法可以处理android webview中的网站弹出窗口,例如在新标签页中打开或使用webview在新窗口中打开.

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.

我也无法在正常浏览器中打开在新窗口中打开的网址.如果我打开了Twitter的某些链接,则该网址未加载,但看到Twitter徽标类似于以下问题之一

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

这是普通android浏览器的快照,但这是作为普通页面而不是弹出窗口加载到我的web视图中的

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

推荐答案

尝试

 webViewObject.getSettings().setJavaScriptCanOpenWindowsAutomatically(true)

如果您要打开窗口...如window.open,则需要此窗口. javascriptenable应该设置为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.

这篇关于如何在Android WebView中使用弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆